weave-typescript 0.34.0 → 0.35.0

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.
@@ -523,4 +523,170 @@ export interface MarkApplicationSessionOrganizationSessionStateRow {
523
523
  }
524
524
  export declare function markApplicationSessionOrganizationSessionState(client: Client, args: MarkApplicationSessionOrganizationSessionStateArgs): Promise<MarkApplicationSessionOrganizationSessionStateRow | null>;
525
525
  export declare const deleteExpiredApplicationSessionsQuery = "-- name: DeleteExpiredApplicationSessions :execrows\nDELETE FROM weave.application_sessions\nWHERE expires_at <= now()\n OR status IN ('revoked', 'expired')";
526
+ export declare const createAuthInviteSessionQuery = "-- name: CreateAuthInviteSession :one\nINSERT INTO weave.auth_invite_sessions (\n organization_id,\n user_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n email,\n display_name,\n role_ids,\n return_url,\n expires_at\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10,\n $11,\n $12\n)\nRETURNING\n id,\n organization_id,\n user_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n email,\n display_name,\n role_ids,\n status,\n recovery_reason,\n return_url,\n oauth_provider,\n oauth_state,\n oauth_return_url,\n expires_at,\n completed_at,\n revoked_at,\n created_at,\n updated_at";
527
+ export interface CreateAuthInviteSessionArgs {
528
+ organizationId: string;
529
+ userId: string;
530
+ identityLinkId: string | null;
531
+ stytchOrganizationId: string;
532
+ stytchMemberId: string;
533
+ stytchMemberSessionId: string;
534
+ stytchSessionTokenCiphertext: Buffer | null;
535
+ email: string;
536
+ displayName: string;
537
+ roleIds: string[];
538
+ returnUrl: string;
539
+ expiresAt: Date;
540
+ }
541
+ export interface CreateAuthInviteSessionRow {
542
+ id: string;
543
+ organizationId: string;
544
+ userId: string;
545
+ identityLinkId: string | null;
546
+ stytchOrganizationId: string;
547
+ stytchMemberId: string;
548
+ stytchMemberSessionId: string;
549
+ stytchSessionTokenCiphertext: Buffer | null;
550
+ email: string;
551
+ displayName: string;
552
+ roleIds: string[];
553
+ status: string;
554
+ recoveryReason: string;
555
+ returnUrl: string;
556
+ oauthProvider: string;
557
+ oauthState: string;
558
+ oauthReturnUrl: string;
559
+ expiresAt: Date;
560
+ completedAt: Date | null;
561
+ revokedAt: Date | null;
562
+ createdAt: Date;
563
+ updatedAt: Date;
564
+ }
565
+ export declare function createAuthInviteSession(client: Client, args: CreateAuthInviteSessionArgs): Promise<CreateAuthInviteSessionRow | null>;
566
+ export declare const getAuthInviteSessionQuery = "-- name: GetAuthInviteSession :one\nSELECT\n id,\n organization_id,\n user_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n email,\n display_name,\n role_ids,\n status,\n recovery_reason,\n return_url,\n oauth_provider,\n oauth_state,\n oauth_return_url,\n expires_at,\n completed_at,\n revoked_at,\n created_at,\n updated_at\nFROM weave.auth_invite_sessions\nWHERE id = $1";
567
+ export interface GetAuthInviteSessionArgs {
568
+ id: string;
569
+ }
570
+ export interface GetAuthInviteSessionRow {
571
+ id: string;
572
+ organizationId: string;
573
+ userId: string;
574
+ identityLinkId: string | null;
575
+ stytchOrganizationId: string;
576
+ stytchMemberId: string;
577
+ stytchMemberSessionId: string;
578
+ stytchSessionTokenCiphertext: Buffer | null;
579
+ email: string;
580
+ displayName: string;
581
+ roleIds: string[];
582
+ status: string;
583
+ recoveryReason: string;
584
+ returnUrl: string;
585
+ oauthProvider: string;
586
+ oauthState: string;
587
+ oauthReturnUrl: string;
588
+ expiresAt: Date;
589
+ completedAt: Date | null;
590
+ revokedAt: Date | null;
591
+ createdAt: Date;
592
+ updatedAt: Date;
593
+ }
594
+ export declare function getAuthInviteSession(client: Client, args: GetAuthInviteSessionArgs): Promise<GetAuthInviteSessionRow | null>;
595
+ export declare const setAuthInviteSessionOAuthStateQuery = "-- name: SetAuthInviteSessionOAuthState :one\nUPDATE weave.auth_invite_sessions\nSET\n oauth_provider = $1,\n oauth_state = $2,\n oauth_return_url = $3,\n updated_at = now()\nWHERE id = $4\n AND status = 'ready'\n AND expires_at > now()\nRETURNING\n id,\n organization_id,\n user_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n email,\n display_name,\n role_ids,\n status,\n recovery_reason,\n return_url,\n oauth_provider,\n oauth_state,\n oauth_return_url,\n expires_at,\n completed_at,\n revoked_at,\n created_at,\n updated_at";
596
+ export interface SetAuthInviteSessionOAuthStateArgs {
597
+ oauthProvider: string;
598
+ oauthState: string;
599
+ oauthReturnUrl: string;
600
+ id: string;
601
+ }
602
+ export interface SetAuthInviteSessionOAuthStateRow {
603
+ id: string;
604
+ organizationId: string;
605
+ userId: string;
606
+ identityLinkId: string | null;
607
+ stytchOrganizationId: string;
608
+ stytchMemberId: string;
609
+ stytchMemberSessionId: string;
610
+ stytchSessionTokenCiphertext: Buffer | null;
611
+ email: string;
612
+ displayName: string;
613
+ roleIds: string[];
614
+ status: string;
615
+ recoveryReason: string;
616
+ returnUrl: string;
617
+ oauthProvider: string;
618
+ oauthState: string;
619
+ oauthReturnUrl: string;
620
+ expiresAt: Date;
621
+ completedAt: Date | null;
622
+ revokedAt: Date | null;
623
+ createdAt: Date;
624
+ updatedAt: Date;
625
+ }
626
+ export declare function setAuthInviteSessionOAuthState(client: Client, args: SetAuthInviteSessionOAuthStateArgs): Promise<SetAuthInviteSessionOAuthStateRow | null>;
627
+ export declare const markAuthInviteSessionCompletedQuery = "-- name: MarkAuthInviteSessionCompleted :one\nUPDATE weave.auth_invite_sessions\nSET\n status = 'completed',\n completed_at = now(),\n updated_at = now()\nWHERE id = $1\n AND status = 'ready'\n AND expires_at > now()\nRETURNING\n id,\n organization_id,\n user_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n email,\n display_name,\n role_ids,\n status,\n recovery_reason,\n return_url,\n oauth_provider,\n oauth_state,\n oauth_return_url,\n expires_at,\n completed_at,\n revoked_at,\n created_at,\n updated_at";
628
+ export interface MarkAuthInviteSessionCompletedArgs {
629
+ id: string;
630
+ }
631
+ export interface MarkAuthInviteSessionCompletedRow {
632
+ id: string;
633
+ organizationId: string;
634
+ userId: string;
635
+ identityLinkId: string | null;
636
+ stytchOrganizationId: string;
637
+ stytchMemberId: string;
638
+ stytchMemberSessionId: string;
639
+ stytchSessionTokenCiphertext: Buffer | null;
640
+ email: string;
641
+ displayName: string;
642
+ roleIds: string[];
643
+ status: string;
644
+ recoveryReason: string;
645
+ returnUrl: string;
646
+ oauthProvider: string;
647
+ oauthState: string;
648
+ oauthReturnUrl: string;
649
+ expiresAt: Date;
650
+ completedAt: Date | null;
651
+ revokedAt: Date | null;
652
+ createdAt: Date;
653
+ updatedAt: Date;
654
+ }
655
+ export declare function markAuthInviteSessionCompleted(client: Client, args: MarkAuthInviteSessionCompletedArgs): Promise<MarkAuthInviteSessionCompletedRow | null>;
656
+ export declare const markAuthInviteSessionRecoveryRequiredQuery = "-- name: MarkAuthInviteSessionRecoveryRequired :one\nUPDATE weave.auth_invite_sessions\nSET\n status = 'recovery_required',\n recovery_reason = $1,\n updated_at = now()\nWHERE id = $2\n AND status IN ('ready', 'expired', 'recovery_required')\nRETURNING\n id,\n organization_id,\n user_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n email,\n display_name,\n role_ids,\n status,\n recovery_reason,\n return_url,\n oauth_provider,\n oauth_state,\n oauth_return_url,\n expires_at,\n completed_at,\n revoked_at,\n created_at,\n updated_at";
657
+ export interface MarkAuthInviteSessionRecoveryRequiredArgs {
658
+ recoveryReason: string;
659
+ id: string;
660
+ }
661
+ export interface MarkAuthInviteSessionRecoveryRequiredRow {
662
+ id: string;
663
+ organizationId: string;
664
+ userId: string;
665
+ identityLinkId: string | null;
666
+ stytchOrganizationId: string;
667
+ stytchMemberId: string;
668
+ stytchMemberSessionId: string;
669
+ stytchSessionTokenCiphertext: Buffer | null;
670
+ email: string;
671
+ displayName: string;
672
+ roleIds: string[];
673
+ status: string;
674
+ recoveryReason: string;
675
+ returnUrl: string;
676
+ oauthProvider: string;
677
+ oauthState: string;
678
+ oauthReturnUrl: string;
679
+ expiresAt: Date;
680
+ completedAt: Date | null;
681
+ revokedAt: Date | null;
682
+ createdAt: Date;
683
+ updatedAt: Date;
684
+ }
685
+ export declare function markAuthInviteSessionRecoveryRequired(client: Client, args: MarkAuthInviteSessionRecoveryRequiredArgs): Promise<MarkAuthInviteSessionRecoveryRequiredRow | null>;
686
+ export declare const revokeAuthInviteSessionsByMemberQuery = "-- name: RevokeAuthInviteSessionsByMember :execrows\nUPDATE weave.auth_invite_sessions\nSET\n status = 'revoked',\n revoked_at = now(),\n updated_at = now()\nWHERE stytch_organization_id = $1\n AND stytch_member_id = $2\n AND status = 'ready'";
687
+ export interface RevokeAuthInviteSessionsByMemberArgs {
688
+ stytchOrganizationId: string;
689
+ stytchMemberId: string;
690
+ }
691
+ export declare const deleteExpiredAuthInviteSessionsQuery = "-- name: DeleteExpiredAuthInviteSessions :execrows\nDELETE FROM weave.auth_invite_sessions\nWHERE expires_at <= now()\n OR status IN ('completed', 'expired', 'revoked')";
526
692
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteExpiredApplicationSessionsQuery = exports.markApplicationSessionOrganizationSessionStateQuery = exports.listApplicationSessionOrganizationSessionStatesQuery = exports.getApplicationSessionOrganizationSessionQuery = exports.upsertApplicationSessionOrganizationSessionQuery = exports.revokeApplicationSessionQuery = exports.setApplicationSessionActiveOrganizationQuery = exports.getApplicationSessionQuery = exports.createApplicationSessionQuery = exports.insertAuthAuditEventQuery = exports.endSupportAccessSessionQuery = exports.createSupportAccessSessionQuery = exports.createPlatformAdminGrantQuery = exports.listActivePlatformAdminGrantsForUserQuery = exports.listOrganizationMembersQuery = exports.listOrganizationMembershipsForUserQuery = exports.getOrganizationMembershipQuery = exports.upsertOrganizationMembershipQuery = exports.upsertOrganizationAuthLinkQuery = exports.getOrganizationAuthLinkByOrganizationIDQuery = exports.getOrganizationAuthLinkByStytchIDQuery = exports.upsertIdentityLinkQuery = exports.getIdentityLinkByStytchMemberQuery = exports.getUserProfileQuery = exports.upsertUserProfileQuery = exports.deleteOrganizationAuthDomainQuery = exports.listOrganizationAuthDomainsQuery = exports.upsertOrganizationAuthDomainQuery = exports.resolvePrimaryOrganizationAuthLinkByDomainQuery = exports.getUserPrimaryOrganizationAuthLinkQuery = exports.setUserPrimaryOrganizationQuery = exports.getUserByIDQuery = exports.createUserQuery = void 0;
3
+ exports.deleteExpiredAuthInviteSessionsQuery = exports.revokeAuthInviteSessionsByMemberQuery = exports.markAuthInviteSessionRecoveryRequiredQuery = exports.markAuthInviteSessionCompletedQuery = exports.setAuthInviteSessionOAuthStateQuery = exports.getAuthInviteSessionQuery = exports.createAuthInviteSessionQuery = exports.deleteExpiredApplicationSessionsQuery = exports.markApplicationSessionOrganizationSessionStateQuery = exports.listApplicationSessionOrganizationSessionStatesQuery = exports.getApplicationSessionOrganizationSessionQuery = exports.upsertApplicationSessionOrganizationSessionQuery = exports.revokeApplicationSessionQuery = exports.setApplicationSessionActiveOrganizationQuery = exports.getApplicationSessionQuery = exports.createApplicationSessionQuery = exports.insertAuthAuditEventQuery = exports.endSupportAccessSessionQuery = exports.createSupportAccessSessionQuery = exports.createPlatformAdminGrantQuery = exports.listActivePlatformAdminGrantsForUserQuery = exports.listOrganizationMembersQuery = exports.listOrganizationMembershipsForUserQuery = exports.getOrganizationMembershipQuery = exports.upsertOrganizationMembershipQuery = exports.upsertOrganizationAuthLinkQuery = exports.getOrganizationAuthLinkByOrganizationIDQuery = exports.getOrganizationAuthLinkByStytchIDQuery = exports.upsertIdentityLinkQuery = exports.getIdentityLinkByStytchMemberQuery = exports.getUserProfileQuery = exports.upsertUserProfileQuery = exports.deleteOrganizationAuthDomainQuery = exports.listOrganizationAuthDomainsQuery = exports.upsertOrganizationAuthDomainQuery = exports.resolvePrimaryOrganizationAuthLinkByDomainQuery = exports.getUserPrimaryOrganizationAuthLinkQuery = exports.setUserPrimaryOrganizationQuery = exports.getUserByIDQuery = exports.createUserQuery = void 0;
4
4
  exports.createUser = createUser;
5
5
  exports.getUserByID = getUserByID;
6
6
  exports.setUserPrimaryOrganization = setUserPrimaryOrganization;
@@ -30,6 +30,11 @@ exports.upsertApplicationSessionOrganizationSession = upsertApplicationSessionOr
30
30
  exports.getApplicationSessionOrganizationSession = getApplicationSessionOrganizationSession;
31
31
  exports.listApplicationSessionOrganizationSessionStates = listApplicationSessionOrganizationSessionStates;
32
32
  exports.markApplicationSessionOrganizationSessionState = markApplicationSessionOrganizationSessionState;
33
+ exports.createAuthInviteSession = createAuthInviteSession;
34
+ exports.getAuthInviteSession = getAuthInviteSession;
35
+ exports.setAuthInviteSessionOAuthState = setAuthInviteSessionOAuthState;
36
+ exports.markAuthInviteSessionCompleted = markAuthInviteSessionCompleted;
37
+ exports.markAuthInviteSessionRecoveryRequired = markAuthInviteSessionRecoveryRequired;
33
38
  exports.createUserQuery = `-- name: CreateUser :one
34
39
  INSERT INTO weave.users (status)
35
40
  VALUES ($1)
@@ -1235,3 +1240,364 @@ exports.deleteExpiredApplicationSessionsQuery = `-- name: DeleteExpiredApplicati
1235
1240
  DELETE FROM weave.application_sessions
1236
1241
  WHERE expires_at <= now()
1237
1242
  OR status IN ('revoked', 'expired')`;
1243
+ exports.createAuthInviteSessionQuery = `-- name: CreateAuthInviteSession :one
1244
+ INSERT INTO weave.auth_invite_sessions (
1245
+ organization_id,
1246
+ user_id,
1247
+ identity_link_id,
1248
+ stytch_organization_id,
1249
+ stytch_member_id,
1250
+ stytch_member_session_id,
1251
+ stytch_session_token_ciphertext,
1252
+ email,
1253
+ display_name,
1254
+ role_ids,
1255
+ return_url,
1256
+ expires_at
1257
+ ) VALUES (
1258
+ $1,
1259
+ $2,
1260
+ $3,
1261
+ $4,
1262
+ $5,
1263
+ $6,
1264
+ $7,
1265
+ $8,
1266
+ $9,
1267
+ $10,
1268
+ $11,
1269
+ $12
1270
+ )
1271
+ RETURNING
1272
+ id,
1273
+ organization_id,
1274
+ user_id,
1275
+ identity_link_id,
1276
+ stytch_organization_id,
1277
+ stytch_member_id,
1278
+ stytch_member_session_id,
1279
+ stytch_session_token_ciphertext,
1280
+ email,
1281
+ display_name,
1282
+ role_ids,
1283
+ status,
1284
+ recovery_reason,
1285
+ return_url,
1286
+ oauth_provider,
1287
+ oauth_state,
1288
+ oauth_return_url,
1289
+ expires_at,
1290
+ completed_at,
1291
+ revoked_at,
1292
+ created_at,
1293
+ updated_at`;
1294
+ async function createAuthInviteSession(client, args) {
1295
+ const result = await client.query({
1296
+ text: exports.createAuthInviteSessionQuery,
1297
+ values: [args.organizationId, args.userId, args.identityLinkId, args.stytchOrganizationId, args.stytchMemberId, args.stytchMemberSessionId, args.stytchSessionTokenCiphertext, args.email, args.displayName, args.roleIds, args.returnUrl, args.expiresAt],
1298
+ rowMode: "array"
1299
+ });
1300
+ if (result.rows.length !== 1) {
1301
+ return null;
1302
+ }
1303
+ const row = result.rows[0];
1304
+ return {
1305
+ id: row[0],
1306
+ organizationId: row[1],
1307
+ userId: row[2],
1308
+ identityLinkId: row[3],
1309
+ stytchOrganizationId: row[4],
1310
+ stytchMemberId: row[5],
1311
+ stytchMemberSessionId: row[6],
1312
+ stytchSessionTokenCiphertext: row[7],
1313
+ email: row[8],
1314
+ displayName: row[9],
1315
+ roleIds: row[10],
1316
+ status: row[11],
1317
+ recoveryReason: row[12],
1318
+ returnUrl: row[13],
1319
+ oauthProvider: row[14],
1320
+ oauthState: row[15],
1321
+ oauthReturnUrl: row[16],
1322
+ expiresAt: row[17],
1323
+ completedAt: row[18],
1324
+ revokedAt: row[19],
1325
+ createdAt: row[20],
1326
+ updatedAt: row[21]
1327
+ };
1328
+ }
1329
+ exports.getAuthInviteSessionQuery = `-- name: GetAuthInviteSession :one
1330
+ SELECT
1331
+ id,
1332
+ organization_id,
1333
+ user_id,
1334
+ identity_link_id,
1335
+ stytch_organization_id,
1336
+ stytch_member_id,
1337
+ stytch_member_session_id,
1338
+ stytch_session_token_ciphertext,
1339
+ email,
1340
+ display_name,
1341
+ role_ids,
1342
+ status,
1343
+ recovery_reason,
1344
+ return_url,
1345
+ oauth_provider,
1346
+ oauth_state,
1347
+ oauth_return_url,
1348
+ expires_at,
1349
+ completed_at,
1350
+ revoked_at,
1351
+ created_at,
1352
+ updated_at
1353
+ FROM weave.auth_invite_sessions
1354
+ WHERE id = $1`;
1355
+ async function getAuthInviteSession(client, args) {
1356
+ const result = await client.query({
1357
+ text: exports.getAuthInviteSessionQuery,
1358
+ values: [args.id],
1359
+ rowMode: "array"
1360
+ });
1361
+ if (result.rows.length !== 1) {
1362
+ return null;
1363
+ }
1364
+ const row = result.rows[0];
1365
+ return {
1366
+ id: row[0],
1367
+ organizationId: row[1],
1368
+ userId: row[2],
1369
+ identityLinkId: row[3],
1370
+ stytchOrganizationId: row[4],
1371
+ stytchMemberId: row[5],
1372
+ stytchMemberSessionId: row[6],
1373
+ stytchSessionTokenCiphertext: row[7],
1374
+ email: row[8],
1375
+ displayName: row[9],
1376
+ roleIds: row[10],
1377
+ status: row[11],
1378
+ recoveryReason: row[12],
1379
+ returnUrl: row[13],
1380
+ oauthProvider: row[14],
1381
+ oauthState: row[15],
1382
+ oauthReturnUrl: row[16],
1383
+ expiresAt: row[17],
1384
+ completedAt: row[18],
1385
+ revokedAt: row[19],
1386
+ createdAt: row[20],
1387
+ updatedAt: row[21]
1388
+ };
1389
+ }
1390
+ exports.setAuthInviteSessionOAuthStateQuery = `-- name: SetAuthInviteSessionOAuthState :one
1391
+ UPDATE weave.auth_invite_sessions
1392
+ SET
1393
+ oauth_provider = $1,
1394
+ oauth_state = $2,
1395
+ oauth_return_url = $3,
1396
+ updated_at = now()
1397
+ WHERE id = $4
1398
+ AND status = 'ready'
1399
+ AND expires_at > now()
1400
+ RETURNING
1401
+ id,
1402
+ organization_id,
1403
+ user_id,
1404
+ identity_link_id,
1405
+ stytch_organization_id,
1406
+ stytch_member_id,
1407
+ stytch_member_session_id,
1408
+ stytch_session_token_ciphertext,
1409
+ email,
1410
+ display_name,
1411
+ role_ids,
1412
+ status,
1413
+ recovery_reason,
1414
+ return_url,
1415
+ oauth_provider,
1416
+ oauth_state,
1417
+ oauth_return_url,
1418
+ expires_at,
1419
+ completed_at,
1420
+ revoked_at,
1421
+ created_at,
1422
+ updated_at`;
1423
+ async function setAuthInviteSessionOAuthState(client, args) {
1424
+ const result = await client.query({
1425
+ text: exports.setAuthInviteSessionOAuthStateQuery,
1426
+ values: [args.oauthProvider, args.oauthState, args.oauthReturnUrl, args.id],
1427
+ rowMode: "array"
1428
+ });
1429
+ if (result.rows.length !== 1) {
1430
+ return null;
1431
+ }
1432
+ const row = result.rows[0];
1433
+ return {
1434
+ id: row[0],
1435
+ organizationId: row[1],
1436
+ userId: row[2],
1437
+ identityLinkId: row[3],
1438
+ stytchOrganizationId: row[4],
1439
+ stytchMemberId: row[5],
1440
+ stytchMemberSessionId: row[6],
1441
+ stytchSessionTokenCiphertext: row[7],
1442
+ email: row[8],
1443
+ displayName: row[9],
1444
+ roleIds: row[10],
1445
+ status: row[11],
1446
+ recoveryReason: row[12],
1447
+ returnUrl: row[13],
1448
+ oauthProvider: row[14],
1449
+ oauthState: row[15],
1450
+ oauthReturnUrl: row[16],
1451
+ expiresAt: row[17],
1452
+ completedAt: row[18],
1453
+ revokedAt: row[19],
1454
+ createdAt: row[20],
1455
+ updatedAt: row[21]
1456
+ };
1457
+ }
1458
+ exports.markAuthInviteSessionCompletedQuery = `-- name: MarkAuthInviteSessionCompleted :one
1459
+ UPDATE weave.auth_invite_sessions
1460
+ SET
1461
+ status = 'completed',
1462
+ completed_at = now(),
1463
+ updated_at = now()
1464
+ WHERE id = $1
1465
+ AND status = 'ready'
1466
+ AND expires_at > now()
1467
+ RETURNING
1468
+ id,
1469
+ organization_id,
1470
+ user_id,
1471
+ identity_link_id,
1472
+ stytch_organization_id,
1473
+ stytch_member_id,
1474
+ stytch_member_session_id,
1475
+ stytch_session_token_ciphertext,
1476
+ email,
1477
+ display_name,
1478
+ role_ids,
1479
+ status,
1480
+ recovery_reason,
1481
+ return_url,
1482
+ oauth_provider,
1483
+ oauth_state,
1484
+ oauth_return_url,
1485
+ expires_at,
1486
+ completed_at,
1487
+ revoked_at,
1488
+ created_at,
1489
+ updated_at`;
1490
+ async function markAuthInviteSessionCompleted(client, args) {
1491
+ const result = await client.query({
1492
+ text: exports.markAuthInviteSessionCompletedQuery,
1493
+ values: [args.id],
1494
+ rowMode: "array"
1495
+ });
1496
+ if (result.rows.length !== 1) {
1497
+ return null;
1498
+ }
1499
+ const row = result.rows[0];
1500
+ return {
1501
+ id: row[0],
1502
+ organizationId: row[1],
1503
+ userId: row[2],
1504
+ identityLinkId: row[3],
1505
+ stytchOrganizationId: row[4],
1506
+ stytchMemberId: row[5],
1507
+ stytchMemberSessionId: row[6],
1508
+ stytchSessionTokenCiphertext: row[7],
1509
+ email: row[8],
1510
+ displayName: row[9],
1511
+ roleIds: row[10],
1512
+ status: row[11],
1513
+ recoveryReason: row[12],
1514
+ returnUrl: row[13],
1515
+ oauthProvider: row[14],
1516
+ oauthState: row[15],
1517
+ oauthReturnUrl: row[16],
1518
+ expiresAt: row[17],
1519
+ completedAt: row[18],
1520
+ revokedAt: row[19],
1521
+ createdAt: row[20],
1522
+ updatedAt: row[21]
1523
+ };
1524
+ }
1525
+ exports.markAuthInviteSessionRecoveryRequiredQuery = `-- name: MarkAuthInviteSessionRecoveryRequired :one
1526
+ UPDATE weave.auth_invite_sessions
1527
+ SET
1528
+ status = 'recovery_required',
1529
+ recovery_reason = $1,
1530
+ updated_at = now()
1531
+ WHERE id = $2
1532
+ AND status IN ('ready', 'expired', 'recovery_required')
1533
+ RETURNING
1534
+ id,
1535
+ organization_id,
1536
+ user_id,
1537
+ identity_link_id,
1538
+ stytch_organization_id,
1539
+ stytch_member_id,
1540
+ stytch_member_session_id,
1541
+ stytch_session_token_ciphertext,
1542
+ email,
1543
+ display_name,
1544
+ role_ids,
1545
+ status,
1546
+ recovery_reason,
1547
+ return_url,
1548
+ oauth_provider,
1549
+ oauth_state,
1550
+ oauth_return_url,
1551
+ expires_at,
1552
+ completed_at,
1553
+ revoked_at,
1554
+ created_at,
1555
+ updated_at`;
1556
+ async function markAuthInviteSessionRecoveryRequired(client, args) {
1557
+ const result = await client.query({
1558
+ text: exports.markAuthInviteSessionRecoveryRequiredQuery,
1559
+ values: [args.recoveryReason, args.id],
1560
+ rowMode: "array"
1561
+ });
1562
+ if (result.rows.length !== 1) {
1563
+ return null;
1564
+ }
1565
+ const row = result.rows[0];
1566
+ return {
1567
+ id: row[0],
1568
+ organizationId: row[1],
1569
+ userId: row[2],
1570
+ identityLinkId: row[3],
1571
+ stytchOrganizationId: row[4],
1572
+ stytchMemberId: row[5],
1573
+ stytchMemberSessionId: row[6],
1574
+ stytchSessionTokenCiphertext: row[7],
1575
+ email: row[8],
1576
+ displayName: row[9],
1577
+ roleIds: row[10],
1578
+ status: row[11],
1579
+ recoveryReason: row[12],
1580
+ returnUrl: row[13],
1581
+ oauthProvider: row[14],
1582
+ oauthState: row[15],
1583
+ oauthReturnUrl: row[16],
1584
+ expiresAt: row[17],
1585
+ completedAt: row[18],
1586
+ revokedAt: row[19],
1587
+ createdAt: row[20],
1588
+ updatedAt: row[21]
1589
+ };
1590
+ }
1591
+ exports.revokeAuthInviteSessionsByMemberQuery = `-- name: RevokeAuthInviteSessionsByMember :execrows
1592
+ UPDATE weave.auth_invite_sessions
1593
+ SET
1594
+ status = 'revoked',
1595
+ revoked_at = now(),
1596
+ updated_at = now()
1597
+ WHERE stytch_organization_id = $1
1598
+ AND stytch_member_id = $2
1599
+ AND status = 'ready'`;
1600
+ exports.deleteExpiredAuthInviteSessionsQuery = `-- name: DeleteExpiredAuthInviteSessions :execrows
1601
+ DELETE FROM weave.auth_invite_sessions
1602
+ WHERE expires_at <= now()
1603
+ OR status IN ('completed', 'expired', 'revoked')`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weave-typescript",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [