weave-typescript 0.31.0 → 0.32.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.
- package/dist/google/api/annotations.pb.js +1 -1
- package/dist/google/api/http.pb.js +1 -1
- package/dist/google/protobuf/descriptor.pb.js +1 -1
- package/dist/google/protobuf/struct.pb.js +1 -1
- package/dist/google/protobuf/timestamp.pb.js +1 -1
- package/dist/weaveapi/atc/v1/event.pb.js +1 -1
- package/dist/weaveapi/atc/v1/message.pb.js +1 -1
- package/dist/weaveapi/atc/v1/process.pb.js +1 -1
- package/dist/weaveapi/atc/v1/run.pb.js +1 -1
- package/dist/weaveapi/atc/v1/service.pb.js +1 -1
- package/dist/weaveapi/auth/v1/auth.pb.js +1 -1
- package/dist/weaveapi/auth/v1/service.pb.js +1 -1
- package/dist/weaveapi/chat/v1/chat.pb.js +1 -1
- package/dist/weaveapi/chat/v1/service.pb.js +1 -1
- package/dist/weaveapi/consolidation/v1/consolidation.pb.js +1 -1
- package/dist/weaveapi/consolidation/v1/service.pb.js +1 -1
- package/dist/weaveapi/inference/v1/inference.pb.js +1 -1
- package/dist/weaveapi/inference/v1/service.pb.js +1 -1
- package/dist/weaveapi/ingestion/v1/ingestion.pb.js +1 -1
- package/dist/weaveapi/ingestion/v1/service.pb.js +1 -1
- package/dist/weaveapi/model/v1/model.pb.js +1 -1
- package/dist/weaveapi/model/v1/service.pb.js +1 -1
- package/dist/weaveapi/organization/v1/organization.pb.js +1 -1
- package/dist/weaveapi/organization/v1/service.pb.js +1 -1
- package/dist/weaveapi/project/v1/project.pb.js +1 -1
- package/dist/weaveapi/project/v1/service.pb.js +1 -1
- package/dist/weaveapi/provider/v1/provider.pb.js +1 -1
- package/dist/weaveapi/provider/v1/service.pb.js +1 -1
- package/dist/weaveapi/retrieval/v1/retrieval.pb.js +1 -1
- package/dist/weaveapi/retrieval/v1/service.pb.js +1 -1
- package/dist/weaveapi/task/v1/service.pb.js +1 -1
- package/dist/weaveapi/task/v1/task.pb.js +1 -1
- package/dist/weavesql/weavedb/auth_identity_sql.d.ts +230 -0
- package/dist/weavesql/weavedb/auth_identity_sql.js +544 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: google/api/annotations.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: google/api/http.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: google/protobuf/descriptor.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: google/protobuf/struct.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: google/protobuf/timestamp.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/atc/v1/event.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/atc/v1/message.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/atc/v1/process.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/atc/v1/run.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/atc/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/auth/v1/auth.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/auth/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/chat/v1/chat.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/chat/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/consolidation/v1/consolidation.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/consolidation/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/inference/v1/inference.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/inference/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/ingestion/v1/ingestion.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/ingestion/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/model/v1/model.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/model/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/organization/v1/organization.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/organization/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/project/v1/project.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/project/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/provider/v1/provider.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/provider/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/retrieval/v1/retrieval.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/retrieval/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/task/v1/service.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
3
3
|
// versions:
|
|
4
|
-
// protoc-gen-ts_proto v2.11.
|
|
4
|
+
// protoc-gen-ts_proto v2.11.7
|
|
5
5
|
// protoc unknown
|
|
6
6
|
// source: weaveapi/task/v1/task.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -24,6 +24,90 @@ export interface GetUserByIDRow {
|
|
|
24
24
|
updatedAt: Date;
|
|
25
25
|
}
|
|
26
26
|
export declare function getUserByID(client: Client, args: GetUserByIDArgs): Promise<GetUserByIDRow | null>;
|
|
27
|
+
export declare const setUserPrimaryOrganizationQuery = "-- name: SetUserPrimaryOrganization :one\nUPDATE weave.users\nSET\n primary_organization_id = $1,\n updated_at = now()\nWHERE id = $2\nRETURNING\n id,\n primary_organization_id,\n status,\n created_at,\n updated_at";
|
|
28
|
+
export interface SetUserPrimaryOrganizationArgs {
|
|
29
|
+
organizationId: string | null;
|
|
30
|
+
userId: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SetUserPrimaryOrganizationRow {
|
|
33
|
+
id: string;
|
|
34
|
+
primaryOrganizationId: string | null;
|
|
35
|
+
status: string;
|
|
36
|
+
createdAt: Date;
|
|
37
|
+
updatedAt: Date;
|
|
38
|
+
}
|
|
39
|
+
export declare function setUserPrimaryOrganization(client: Client, args: SetUserPrimaryOrganizationArgs): Promise<SetUserPrimaryOrganizationRow | null>;
|
|
40
|
+
export declare const getUserPrimaryOrganizationAuthLinkQuery = "-- name: GetUserPrimaryOrganizationAuthLink :one\nSELECT\n o.id AS organization_id,\n o.slug AS organization_slug,\n o.name AS organization_name,\n l.stytch_organization_id,\n l.stytch_organization_slug,\n l.stytch_organization_kind,\n l.allowed_domains,\n l.auth_policy_summary,\n l.created_at,\n l.updated_at\nFROM weave.users AS u\nJOIN weave.organizations AS o\n ON o.id = u.primary_organization_id\nJOIN weave.organization_auth_links AS l\n ON l.organization_id = o.id\nWHERE u.id = $1\n AND u.status = 'active'";
|
|
41
|
+
export interface GetUserPrimaryOrganizationAuthLinkArgs {
|
|
42
|
+
userId: string;
|
|
43
|
+
}
|
|
44
|
+
export interface GetUserPrimaryOrganizationAuthLinkRow {
|
|
45
|
+
organizationId: string;
|
|
46
|
+
organizationSlug: string;
|
|
47
|
+
organizationName: string;
|
|
48
|
+
stytchOrganizationId: string;
|
|
49
|
+
stytchOrganizationSlug: string;
|
|
50
|
+
stytchOrganizationKind: string;
|
|
51
|
+
allowedDomains: string[];
|
|
52
|
+
authPolicySummary: any;
|
|
53
|
+
createdAt: Date;
|
|
54
|
+
updatedAt: Date;
|
|
55
|
+
}
|
|
56
|
+
export declare function getUserPrimaryOrganizationAuthLink(client: Client, args: GetUserPrimaryOrganizationAuthLinkArgs): Promise<GetUserPrimaryOrganizationAuthLinkRow | null>;
|
|
57
|
+
export declare const resolvePrimaryOrganizationAuthLinkByDomainQuery = "-- name: ResolvePrimaryOrganizationAuthLinkByDomain :one\nSELECT\n o.id AS organization_id,\n o.slug AS organization_slug,\n o.name AS organization_name,\n l.stytch_organization_id,\n l.stytch_organization_slug,\n l.stytch_organization_kind,\n d.domain,\n l.allowed_domains,\n l.auth_policy_summary,\n l.created_at,\n l.updated_at\nFROM weave.organization_auth_domains AS d\nJOIN weave.organization_auth_links AS l\n ON l.organization_id = d.organization_id\nJOIN weave.organizations AS o\n ON o.id = d.organization_id\nWHERE d.domain = lower($1)\n AND d.is_primary_login\n AND d.status = 'active'";
|
|
58
|
+
export interface ResolvePrimaryOrganizationAuthLinkByDomainArgs {
|
|
59
|
+
domain: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ResolvePrimaryOrganizationAuthLinkByDomainRow {
|
|
62
|
+
organizationId: string;
|
|
63
|
+
organizationSlug: string;
|
|
64
|
+
organizationName: string;
|
|
65
|
+
stytchOrganizationId: string;
|
|
66
|
+
stytchOrganizationSlug: string;
|
|
67
|
+
stytchOrganizationKind: string;
|
|
68
|
+
domain: string;
|
|
69
|
+
allowedDomains: string[];
|
|
70
|
+
authPolicySummary: any;
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
updatedAt: Date;
|
|
73
|
+
}
|
|
74
|
+
export declare function resolvePrimaryOrganizationAuthLinkByDomain(client: Client, args: ResolvePrimaryOrganizationAuthLinkByDomainArgs): Promise<ResolvePrimaryOrganizationAuthLinkByDomainRow | null>;
|
|
75
|
+
export declare const upsertOrganizationAuthDomainQuery = "-- name: UpsertOrganizationAuthDomain :one\nINSERT INTO weave.organization_auth_domains (\n organization_id,\n domain,\n is_primary_login,\n status\n) VALUES (\n $1,\n lower($2),\n $3,\n $4\n)\nON CONFLICT (organization_id, domain) DO UPDATE\nSET\n is_primary_login = EXCLUDED.is_primary_login,\n status = EXCLUDED.status,\n updated_at = now()\nRETURNING\n id,\n organization_id,\n domain,\n is_primary_login,\n status,\n created_at,\n updated_at";
|
|
76
|
+
export interface UpsertOrganizationAuthDomainArgs {
|
|
77
|
+
organizationId: string;
|
|
78
|
+
domain: string;
|
|
79
|
+
isPrimaryLogin: boolean;
|
|
80
|
+
status: string;
|
|
81
|
+
}
|
|
82
|
+
export interface UpsertOrganizationAuthDomainRow {
|
|
83
|
+
id: string;
|
|
84
|
+
organizationId: string;
|
|
85
|
+
domain: string;
|
|
86
|
+
isPrimaryLogin: boolean;
|
|
87
|
+
status: string;
|
|
88
|
+
createdAt: Date;
|
|
89
|
+
updatedAt: Date;
|
|
90
|
+
}
|
|
91
|
+
export declare function upsertOrganizationAuthDomain(client: Client, args: UpsertOrganizationAuthDomainArgs): Promise<UpsertOrganizationAuthDomainRow | null>;
|
|
92
|
+
export declare const listOrganizationAuthDomainsQuery = "-- name: ListOrganizationAuthDomains :many\nSELECT\n id,\n organization_id,\n domain,\n is_primary_login,\n status,\n created_at,\n updated_at\nFROM weave.organization_auth_domains\nWHERE organization_id = $1\nORDER BY is_primary_login DESC, domain ASC";
|
|
93
|
+
export interface ListOrganizationAuthDomainsArgs {
|
|
94
|
+
organizationId: string;
|
|
95
|
+
}
|
|
96
|
+
export interface ListOrganizationAuthDomainsRow {
|
|
97
|
+
id: string;
|
|
98
|
+
organizationId: string;
|
|
99
|
+
domain: string;
|
|
100
|
+
isPrimaryLogin: boolean;
|
|
101
|
+
status: string;
|
|
102
|
+
createdAt: Date;
|
|
103
|
+
updatedAt: Date;
|
|
104
|
+
}
|
|
105
|
+
export declare function listOrganizationAuthDomains(client: Client, args: ListOrganizationAuthDomainsArgs): Promise<ListOrganizationAuthDomainsRow[]>;
|
|
106
|
+
export declare const deleteOrganizationAuthDomainQuery = "-- name: DeleteOrganizationAuthDomain :execrows\nDELETE FROM weave.organization_auth_domains\nWHERE organization_id = $1\n AND domain = lower($2)";
|
|
107
|
+
export interface DeleteOrganizationAuthDomainArgs {
|
|
108
|
+
organizationId: string;
|
|
109
|
+
domain: string;
|
|
110
|
+
}
|
|
27
111
|
export declare const upsertUserProfileQuery = "-- name: UpsertUserProfile :one\nINSERT INTO weave.user_profiles (\n user_id,\n display_name,\n job_title,\n email,\n avatar_url,\n theme\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6\n)\nON CONFLICT (user_id) DO UPDATE\nSET\n display_name = EXCLUDED.display_name,\n job_title = EXCLUDED.job_title,\n email = EXCLUDED.email,\n avatar_url = EXCLUDED.avatar_url,\n theme = EXCLUDED.theme,\n updated_at = now()\nRETURNING\n user_id,\n display_name,\n job_title,\n email,\n avatar_url,\n theme,\n created_at,\n updated_at";
|
|
28
112
|
export interface UpsertUserProfileArgs {
|
|
29
113
|
userId: string;
|
|
@@ -292,4 +376,150 @@ export interface InsertAuthAuditEventArgs {
|
|
|
292
376
|
metadata: any;
|
|
293
377
|
}
|
|
294
378
|
export declare function insertAuthAuditEvent(client: Client, args: InsertAuthAuditEventArgs): Promise<void>;
|
|
379
|
+
export declare const createApplicationSessionQuery = "-- name: CreateApplicationSession :one\nINSERT INTO weave.application_sessions (\n user_id,\n active_organization_id,\n expires_at\n) VALUES (\n $1,\n $2,\n $3\n)\nRETURNING\n id,\n user_id,\n active_organization_id,\n status,\n expires_at,\n revoked_at,\n created_at,\n updated_at";
|
|
380
|
+
export interface CreateApplicationSessionArgs {
|
|
381
|
+
userId: string;
|
|
382
|
+
activeOrganizationId: string | null;
|
|
383
|
+
expiresAt: Date;
|
|
384
|
+
}
|
|
385
|
+
export interface CreateApplicationSessionRow {
|
|
386
|
+
id: string;
|
|
387
|
+
userId: string;
|
|
388
|
+
activeOrganizationId: string | null;
|
|
389
|
+
status: string;
|
|
390
|
+
expiresAt: Date;
|
|
391
|
+
revokedAt: Date | null;
|
|
392
|
+
createdAt: Date;
|
|
393
|
+
updatedAt: Date;
|
|
394
|
+
}
|
|
395
|
+
export declare function createApplicationSession(client: Client, args: CreateApplicationSessionArgs): Promise<CreateApplicationSessionRow | null>;
|
|
396
|
+
export declare const getApplicationSessionQuery = "-- name: GetApplicationSession :one\nSELECT\n id,\n user_id,\n active_organization_id,\n status,\n expires_at,\n revoked_at,\n created_at,\n updated_at\nFROM weave.application_sessions\nWHERE id = $1";
|
|
397
|
+
export interface GetApplicationSessionArgs {
|
|
398
|
+
id: string;
|
|
399
|
+
}
|
|
400
|
+
export interface GetApplicationSessionRow {
|
|
401
|
+
id: string;
|
|
402
|
+
userId: string;
|
|
403
|
+
activeOrganizationId: string | null;
|
|
404
|
+
status: string;
|
|
405
|
+
expiresAt: Date;
|
|
406
|
+
revokedAt: Date | null;
|
|
407
|
+
createdAt: Date;
|
|
408
|
+
updatedAt: Date;
|
|
409
|
+
}
|
|
410
|
+
export declare function getApplicationSession(client: Client, args: GetApplicationSessionArgs): Promise<GetApplicationSessionRow | null>;
|
|
411
|
+
export declare const setApplicationSessionActiveOrganizationQuery = "-- name: SetApplicationSessionActiveOrganization :one\nUPDATE weave.application_sessions\nSET\n active_organization_id = $1,\n updated_at = now()\nWHERE id = $2\n AND status = 'active'\nRETURNING\n id,\n user_id,\n active_organization_id,\n status,\n expires_at,\n revoked_at,\n created_at,\n updated_at";
|
|
412
|
+
export interface SetApplicationSessionActiveOrganizationArgs {
|
|
413
|
+
organizationId: string | null;
|
|
414
|
+
id: string;
|
|
415
|
+
}
|
|
416
|
+
export interface SetApplicationSessionActiveOrganizationRow {
|
|
417
|
+
id: string;
|
|
418
|
+
userId: string;
|
|
419
|
+
activeOrganizationId: string | null;
|
|
420
|
+
status: string;
|
|
421
|
+
expiresAt: Date;
|
|
422
|
+
revokedAt: Date | null;
|
|
423
|
+
createdAt: Date;
|
|
424
|
+
updatedAt: Date;
|
|
425
|
+
}
|
|
426
|
+
export declare function setApplicationSessionActiveOrganization(client: Client, args: SetApplicationSessionActiveOrganizationArgs): Promise<SetApplicationSessionActiveOrganizationRow | null>;
|
|
427
|
+
export declare const revokeApplicationSessionQuery = "-- name: RevokeApplicationSession :execrows\nUPDATE weave.application_sessions\nSET\n status = 'revoked',\n revoked_at = now(),\n updated_at = now()\nWHERE id = $1\n AND status = 'active'";
|
|
428
|
+
export interface RevokeApplicationSessionArgs {
|
|
429
|
+
id: string;
|
|
430
|
+
}
|
|
431
|
+
export declare const upsertApplicationSessionOrganizationSessionQuery = "-- name: UpsertApplicationSessionOrganizationSession :one\nINSERT INTO weave.application_session_organization_sessions (\n application_session_id,\n organization_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n auth_state,\n expires_at,\n last_validated_at\n) VALUES (\n $1,\n $2,\n $3,\n $4,\n $5,\n $6,\n $7,\n $8,\n $9,\n $10\n)\nON CONFLICT (application_session_id, organization_id) DO UPDATE\nSET\n identity_link_id = EXCLUDED.identity_link_id,\n stytch_organization_id = EXCLUDED.stytch_organization_id,\n stytch_member_id = EXCLUDED.stytch_member_id,\n stytch_member_session_id = EXCLUDED.stytch_member_session_id,\n stytch_session_token_ciphertext = EXCLUDED.stytch_session_token_ciphertext,\n auth_state = EXCLUDED.auth_state,\n expires_at = EXCLUDED.expires_at,\n last_validated_at = EXCLUDED.last_validated_at,\n updated_at = now()\nRETURNING\n id,\n application_session_id,\n organization_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n auth_state,\n expires_at,\n last_validated_at,\n created_at,\n updated_at";
|
|
432
|
+
export interface UpsertApplicationSessionOrganizationSessionArgs {
|
|
433
|
+
applicationSessionId: string;
|
|
434
|
+
organizationId: string;
|
|
435
|
+
identityLinkId: string | null;
|
|
436
|
+
stytchOrganizationId: string;
|
|
437
|
+
stytchMemberId: string;
|
|
438
|
+
stytchMemberSessionId: string;
|
|
439
|
+
stytchSessionTokenCiphertext: Buffer | null;
|
|
440
|
+
authState: string;
|
|
441
|
+
expiresAt: Date;
|
|
442
|
+
lastValidatedAt: Date | null;
|
|
443
|
+
}
|
|
444
|
+
export interface UpsertApplicationSessionOrganizationSessionRow {
|
|
445
|
+
id: string;
|
|
446
|
+
applicationSessionId: string;
|
|
447
|
+
organizationId: string;
|
|
448
|
+
identityLinkId: string | null;
|
|
449
|
+
stytchOrganizationId: string;
|
|
450
|
+
stytchMemberId: string;
|
|
451
|
+
stytchMemberSessionId: string;
|
|
452
|
+
stytchSessionTokenCiphertext: Buffer | null;
|
|
453
|
+
authState: string;
|
|
454
|
+
expiresAt: Date;
|
|
455
|
+
lastValidatedAt: Date | null;
|
|
456
|
+
createdAt: Date;
|
|
457
|
+
updatedAt: Date;
|
|
458
|
+
}
|
|
459
|
+
export declare function upsertApplicationSessionOrganizationSession(client: Client, args: UpsertApplicationSessionOrganizationSessionArgs): Promise<UpsertApplicationSessionOrganizationSessionRow | null>;
|
|
460
|
+
export declare const getApplicationSessionOrganizationSessionQuery = "-- name: GetApplicationSessionOrganizationSession :one\nSELECT\n id,\n application_session_id,\n organization_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n auth_state,\n expires_at,\n last_validated_at,\n created_at,\n updated_at\nFROM weave.application_session_organization_sessions\nWHERE application_session_id = $1\n AND organization_id = $2";
|
|
461
|
+
export interface GetApplicationSessionOrganizationSessionArgs {
|
|
462
|
+
applicationSessionId: string;
|
|
463
|
+
organizationId: string;
|
|
464
|
+
}
|
|
465
|
+
export interface GetApplicationSessionOrganizationSessionRow {
|
|
466
|
+
id: string;
|
|
467
|
+
applicationSessionId: string;
|
|
468
|
+
organizationId: string;
|
|
469
|
+
identityLinkId: string | null;
|
|
470
|
+
stytchOrganizationId: string;
|
|
471
|
+
stytchMemberId: string;
|
|
472
|
+
stytchMemberSessionId: string;
|
|
473
|
+
stytchSessionTokenCiphertext: Buffer | null;
|
|
474
|
+
authState: string;
|
|
475
|
+
expiresAt: Date;
|
|
476
|
+
lastValidatedAt: Date | null;
|
|
477
|
+
createdAt: Date;
|
|
478
|
+
updatedAt: Date;
|
|
479
|
+
}
|
|
480
|
+
export declare function getApplicationSessionOrganizationSession(client: Client, args: GetApplicationSessionOrganizationSessionArgs): Promise<GetApplicationSessionOrganizationSessionRow | null>;
|
|
481
|
+
export declare const listApplicationSessionOrganizationSessionStatesQuery = "-- name: ListApplicationSessionOrganizationSessionStates :many\nSELECT\n s.id,\n s.application_session_id,\n s.organization_id,\n o.slug AS organization_slug,\n o.name AS organization_name,\n s.identity_link_id,\n s.stytch_organization_id,\n s.stytch_member_id,\n s.stytch_member_session_id,\n s.auth_state,\n s.expires_at,\n s.last_validated_at,\n s.created_at,\n s.updated_at\nFROM weave.application_session_organization_sessions AS s\nJOIN weave.organizations AS o\n ON o.id = s.organization_id\nWHERE s.application_session_id = $1\nORDER BY o.slug ASC";
|
|
482
|
+
export interface ListApplicationSessionOrganizationSessionStatesArgs {
|
|
483
|
+
applicationSessionId: string;
|
|
484
|
+
}
|
|
485
|
+
export interface ListApplicationSessionOrganizationSessionStatesRow {
|
|
486
|
+
id: string;
|
|
487
|
+
applicationSessionId: string;
|
|
488
|
+
organizationId: string;
|
|
489
|
+
organizationSlug: string;
|
|
490
|
+
organizationName: string;
|
|
491
|
+
identityLinkId: string | null;
|
|
492
|
+
stytchOrganizationId: string;
|
|
493
|
+
stytchMemberId: string;
|
|
494
|
+
stytchMemberSessionId: string;
|
|
495
|
+
authState: string;
|
|
496
|
+
expiresAt: Date;
|
|
497
|
+
lastValidatedAt: Date | null;
|
|
498
|
+
createdAt: Date;
|
|
499
|
+
updatedAt: Date;
|
|
500
|
+
}
|
|
501
|
+
export declare function listApplicationSessionOrganizationSessionStates(client: Client, args: ListApplicationSessionOrganizationSessionStatesArgs): Promise<ListApplicationSessionOrganizationSessionStatesRow[]>;
|
|
502
|
+
export declare const markApplicationSessionOrganizationSessionStateQuery = "-- name: MarkApplicationSessionOrganizationSessionState :one\nUPDATE weave.application_session_organization_sessions\nSET\n auth_state = $1,\n last_validated_at = now(),\n updated_at = now()\nWHERE application_session_id = $2\n AND organization_id = $3\nRETURNING\n id,\n application_session_id,\n organization_id,\n identity_link_id,\n stytch_organization_id,\n stytch_member_id,\n stytch_member_session_id,\n stytch_session_token_ciphertext,\n auth_state,\n expires_at,\n last_validated_at,\n created_at,\n updated_at";
|
|
503
|
+
export interface MarkApplicationSessionOrganizationSessionStateArgs {
|
|
504
|
+
authState: string;
|
|
505
|
+
applicationSessionId: string;
|
|
506
|
+
organizationId: string;
|
|
507
|
+
}
|
|
508
|
+
export interface MarkApplicationSessionOrganizationSessionStateRow {
|
|
509
|
+
id: string;
|
|
510
|
+
applicationSessionId: string;
|
|
511
|
+
organizationId: string;
|
|
512
|
+
identityLinkId: string | null;
|
|
513
|
+
stytchOrganizationId: string;
|
|
514
|
+
stytchMemberId: string;
|
|
515
|
+
stytchMemberSessionId: string;
|
|
516
|
+
stytchSessionTokenCiphertext: Buffer | null;
|
|
517
|
+
authState: string;
|
|
518
|
+
expiresAt: Date;
|
|
519
|
+
lastValidatedAt: Date | null;
|
|
520
|
+
createdAt: Date;
|
|
521
|
+
updatedAt: Date;
|
|
522
|
+
}
|
|
523
|
+
export declare function markApplicationSessionOrganizationSessionState(client: Client, args: MarkApplicationSessionOrganizationSessionStateArgs): Promise<MarkApplicationSessionOrganizationSessionStateRow | null>;
|
|
524
|
+
export declare const deleteExpiredApplicationSessionsQuery = "-- name: DeleteExpiredApplicationSessions :execrows\nDELETE FROM weave.application_sessions\nWHERE expires_at <= now()\n OR status IN ('revoked', 'expired')";
|
|
295
525
|
export {};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.getUserByIDQuery = exports.createUserQuery = void 0;
|
|
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;
|
|
4
4
|
exports.createUser = createUser;
|
|
5
5
|
exports.getUserByID = getUserByID;
|
|
6
|
+
exports.setUserPrimaryOrganization = setUserPrimaryOrganization;
|
|
7
|
+
exports.getUserPrimaryOrganizationAuthLink = getUserPrimaryOrganizationAuthLink;
|
|
8
|
+
exports.resolvePrimaryOrganizationAuthLinkByDomain = resolvePrimaryOrganizationAuthLinkByDomain;
|
|
9
|
+
exports.upsertOrganizationAuthDomain = upsertOrganizationAuthDomain;
|
|
10
|
+
exports.listOrganizationAuthDomains = listOrganizationAuthDomains;
|
|
6
11
|
exports.upsertUserProfile = upsertUserProfile;
|
|
7
12
|
exports.getUserProfile = getUserProfile;
|
|
8
13
|
exports.getIdentityLinkByStytchMember = getIdentityLinkByStytchMember;
|
|
@@ -18,6 +23,13 @@ exports.listActivePlatformAdminGrantsForUser = listActivePlatformAdminGrantsForU
|
|
|
18
23
|
exports.createPlatformAdminGrant = createPlatformAdminGrant;
|
|
19
24
|
exports.createSupportAccessSession = createSupportAccessSession;
|
|
20
25
|
exports.insertAuthAuditEvent = insertAuthAuditEvent;
|
|
26
|
+
exports.createApplicationSession = createApplicationSession;
|
|
27
|
+
exports.getApplicationSession = getApplicationSession;
|
|
28
|
+
exports.setApplicationSessionActiveOrganization = setApplicationSessionActiveOrganization;
|
|
29
|
+
exports.upsertApplicationSessionOrganizationSession = upsertApplicationSessionOrganizationSession;
|
|
30
|
+
exports.getApplicationSessionOrganizationSession = getApplicationSessionOrganizationSession;
|
|
31
|
+
exports.listApplicationSessionOrganizationSessionStates = listApplicationSessionOrganizationSessionStates;
|
|
32
|
+
exports.markApplicationSessionOrganizationSessionState = markApplicationSessionOrganizationSessionState;
|
|
21
33
|
exports.createUserQuery = `-- name: CreateUser :one
|
|
22
34
|
INSERT INTO weave.users (status)
|
|
23
35
|
VALUES ($1)
|
|
@@ -60,6 +72,202 @@ async function getUserByID(client, args) {
|
|
|
60
72
|
updatedAt: row[3]
|
|
61
73
|
};
|
|
62
74
|
}
|
|
75
|
+
exports.setUserPrimaryOrganizationQuery = `-- name: SetUserPrimaryOrganization :one
|
|
76
|
+
UPDATE weave.users
|
|
77
|
+
SET
|
|
78
|
+
primary_organization_id = $1,
|
|
79
|
+
updated_at = now()
|
|
80
|
+
WHERE id = $2
|
|
81
|
+
RETURNING
|
|
82
|
+
id,
|
|
83
|
+
primary_organization_id,
|
|
84
|
+
status,
|
|
85
|
+
created_at,
|
|
86
|
+
updated_at`;
|
|
87
|
+
async function setUserPrimaryOrganization(client, args) {
|
|
88
|
+
const result = await client.query({
|
|
89
|
+
text: exports.setUserPrimaryOrganizationQuery,
|
|
90
|
+
values: [args.organizationId, args.userId],
|
|
91
|
+
rowMode: "array"
|
|
92
|
+
});
|
|
93
|
+
if (result.rows.length !== 1) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
const row = result.rows[0];
|
|
97
|
+
return {
|
|
98
|
+
id: row[0],
|
|
99
|
+
primaryOrganizationId: row[1],
|
|
100
|
+
status: row[2],
|
|
101
|
+
createdAt: row[3],
|
|
102
|
+
updatedAt: row[4]
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
exports.getUserPrimaryOrganizationAuthLinkQuery = `-- name: GetUserPrimaryOrganizationAuthLink :one
|
|
106
|
+
SELECT
|
|
107
|
+
o.id AS organization_id,
|
|
108
|
+
o.slug AS organization_slug,
|
|
109
|
+
o.name AS organization_name,
|
|
110
|
+
l.stytch_organization_id,
|
|
111
|
+
l.stytch_organization_slug,
|
|
112
|
+
l.stytch_organization_kind,
|
|
113
|
+
l.allowed_domains,
|
|
114
|
+
l.auth_policy_summary,
|
|
115
|
+
l.created_at,
|
|
116
|
+
l.updated_at
|
|
117
|
+
FROM weave.users AS u
|
|
118
|
+
JOIN weave.organizations AS o
|
|
119
|
+
ON o.id = u.primary_organization_id
|
|
120
|
+
JOIN weave.organization_auth_links AS l
|
|
121
|
+
ON l.organization_id = o.id
|
|
122
|
+
WHERE u.id = $1
|
|
123
|
+
AND u.status = 'active'`;
|
|
124
|
+
async function getUserPrimaryOrganizationAuthLink(client, args) {
|
|
125
|
+
const result = await client.query({
|
|
126
|
+
text: exports.getUserPrimaryOrganizationAuthLinkQuery,
|
|
127
|
+
values: [args.userId],
|
|
128
|
+
rowMode: "array"
|
|
129
|
+
});
|
|
130
|
+
if (result.rows.length !== 1) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const row = result.rows[0];
|
|
134
|
+
return {
|
|
135
|
+
organizationId: row[0],
|
|
136
|
+
organizationSlug: row[1],
|
|
137
|
+
organizationName: row[2],
|
|
138
|
+
stytchOrganizationId: row[3],
|
|
139
|
+
stytchOrganizationSlug: row[4],
|
|
140
|
+
stytchOrganizationKind: row[5],
|
|
141
|
+
allowedDomains: row[6],
|
|
142
|
+
authPolicySummary: row[7],
|
|
143
|
+
createdAt: row[8],
|
|
144
|
+
updatedAt: row[9]
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
exports.resolvePrimaryOrganizationAuthLinkByDomainQuery = `-- name: ResolvePrimaryOrganizationAuthLinkByDomain :one
|
|
148
|
+
SELECT
|
|
149
|
+
o.id AS organization_id,
|
|
150
|
+
o.slug AS organization_slug,
|
|
151
|
+
o.name AS organization_name,
|
|
152
|
+
l.stytch_organization_id,
|
|
153
|
+
l.stytch_organization_slug,
|
|
154
|
+
l.stytch_organization_kind,
|
|
155
|
+
d.domain,
|
|
156
|
+
l.allowed_domains,
|
|
157
|
+
l.auth_policy_summary,
|
|
158
|
+
l.created_at,
|
|
159
|
+
l.updated_at
|
|
160
|
+
FROM weave.organization_auth_domains AS d
|
|
161
|
+
JOIN weave.organization_auth_links AS l
|
|
162
|
+
ON l.organization_id = d.organization_id
|
|
163
|
+
JOIN weave.organizations AS o
|
|
164
|
+
ON o.id = d.organization_id
|
|
165
|
+
WHERE d.domain = lower($1)
|
|
166
|
+
AND d.is_primary_login
|
|
167
|
+
AND d.status = 'active'`;
|
|
168
|
+
async function resolvePrimaryOrganizationAuthLinkByDomain(client, args) {
|
|
169
|
+
const result = await client.query({
|
|
170
|
+
text: exports.resolvePrimaryOrganizationAuthLinkByDomainQuery,
|
|
171
|
+
values: [args.domain],
|
|
172
|
+
rowMode: "array"
|
|
173
|
+
});
|
|
174
|
+
if (result.rows.length !== 1) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const row = result.rows[0];
|
|
178
|
+
return {
|
|
179
|
+
organizationId: row[0],
|
|
180
|
+
organizationSlug: row[1],
|
|
181
|
+
organizationName: row[2],
|
|
182
|
+
stytchOrganizationId: row[3],
|
|
183
|
+
stytchOrganizationSlug: row[4],
|
|
184
|
+
stytchOrganizationKind: row[5],
|
|
185
|
+
domain: row[6],
|
|
186
|
+
allowedDomains: row[7],
|
|
187
|
+
authPolicySummary: row[8],
|
|
188
|
+
createdAt: row[9],
|
|
189
|
+
updatedAt: row[10]
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
exports.upsertOrganizationAuthDomainQuery = `-- name: UpsertOrganizationAuthDomain :one
|
|
193
|
+
INSERT INTO weave.organization_auth_domains (
|
|
194
|
+
organization_id,
|
|
195
|
+
domain,
|
|
196
|
+
is_primary_login,
|
|
197
|
+
status
|
|
198
|
+
) VALUES (
|
|
199
|
+
$1,
|
|
200
|
+
lower($2),
|
|
201
|
+
$3,
|
|
202
|
+
$4
|
|
203
|
+
)
|
|
204
|
+
ON CONFLICT (organization_id, domain) DO UPDATE
|
|
205
|
+
SET
|
|
206
|
+
is_primary_login = EXCLUDED.is_primary_login,
|
|
207
|
+
status = EXCLUDED.status,
|
|
208
|
+
updated_at = now()
|
|
209
|
+
RETURNING
|
|
210
|
+
id,
|
|
211
|
+
organization_id,
|
|
212
|
+
domain,
|
|
213
|
+
is_primary_login,
|
|
214
|
+
status,
|
|
215
|
+
created_at,
|
|
216
|
+
updated_at`;
|
|
217
|
+
async function upsertOrganizationAuthDomain(client, args) {
|
|
218
|
+
const result = await client.query({
|
|
219
|
+
text: exports.upsertOrganizationAuthDomainQuery,
|
|
220
|
+
values: [args.organizationId, args.domain, args.isPrimaryLogin, args.status],
|
|
221
|
+
rowMode: "array"
|
|
222
|
+
});
|
|
223
|
+
if (result.rows.length !== 1) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
const row = result.rows[0];
|
|
227
|
+
return {
|
|
228
|
+
id: row[0],
|
|
229
|
+
organizationId: row[1],
|
|
230
|
+
domain: row[2],
|
|
231
|
+
isPrimaryLogin: row[3],
|
|
232
|
+
status: row[4],
|
|
233
|
+
createdAt: row[5],
|
|
234
|
+
updatedAt: row[6]
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
exports.listOrganizationAuthDomainsQuery = `-- name: ListOrganizationAuthDomains :many
|
|
238
|
+
SELECT
|
|
239
|
+
id,
|
|
240
|
+
organization_id,
|
|
241
|
+
domain,
|
|
242
|
+
is_primary_login,
|
|
243
|
+
status,
|
|
244
|
+
created_at,
|
|
245
|
+
updated_at
|
|
246
|
+
FROM weave.organization_auth_domains
|
|
247
|
+
WHERE organization_id = $1
|
|
248
|
+
ORDER BY is_primary_login DESC, domain ASC`;
|
|
249
|
+
async function listOrganizationAuthDomains(client, args) {
|
|
250
|
+
const result = await client.query({
|
|
251
|
+
text: exports.listOrganizationAuthDomainsQuery,
|
|
252
|
+
values: [args.organizationId],
|
|
253
|
+
rowMode: "array"
|
|
254
|
+
});
|
|
255
|
+
return result.rows.map(row => {
|
|
256
|
+
return {
|
|
257
|
+
id: row[0],
|
|
258
|
+
organizationId: row[1],
|
|
259
|
+
domain: row[2],
|
|
260
|
+
isPrimaryLogin: row[3],
|
|
261
|
+
status: row[4],
|
|
262
|
+
createdAt: row[5],
|
|
263
|
+
updatedAt: row[6]
|
|
264
|
+
};
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
exports.deleteOrganizationAuthDomainQuery = `-- name: DeleteOrganizationAuthDomain :execrows
|
|
268
|
+
DELETE FROM weave.organization_auth_domains
|
|
269
|
+
WHERE organization_id = $1
|
|
270
|
+
AND domain = lower($2)`;
|
|
63
271
|
exports.upsertUserProfileQuery = `-- name: UpsertUserProfile :one
|
|
64
272
|
INSERT INTO weave.user_profiles (
|
|
65
273
|
user_id,
|
|
@@ -688,3 +896,338 @@ async function insertAuthAuditEvent(client, args) {
|
|
|
688
896
|
rowMode: "array"
|
|
689
897
|
});
|
|
690
898
|
}
|
|
899
|
+
exports.createApplicationSessionQuery = `-- name: CreateApplicationSession :one
|
|
900
|
+
INSERT INTO weave.application_sessions (
|
|
901
|
+
user_id,
|
|
902
|
+
active_organization_id,
|
|
903
|
+
expires_at
|
|
904
|
+
) VALUES (
|
|
905
|
+
$1,
|
|
906
|
+
$2,
|
|
907
|
+
$3
|
|
908
|
+
)
|
|
909
|
+
RETURNING
|
|
910
|
+
id,
|
|
911
|
+
user_id,
|
|
912
|
+
active_organization_id,
|
|
913
|
+
status,
|
|
914
|
+
expires_at,
|
|
915
|
+
revoked_at,
|
|
916
|
+
created_at,
|
|
917
|
+
updated_at`;
|
|
918
|
+
async function createApplicationSession(client, args) {
|
|
919
|
+
const result = await client.query({
|
|
920
|
+
text: exports.createApplicationSessionQuery,
|
|
921
|
+
values: [args.userId, args.activeOrganizationId, args.expiresAt],
|
|
922
|
+
rowMode: "array"
|
|
923
|
+
});
|
|
924
|
+
if (result.rows.length !== 1) {
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
const row = result.rows[0];
|
|
928
|
+
return {
|
|
929
|
+
id: row[0],
|
|
930
|
+
userId: row[1],
|
|
931
|
+
activeOrganizationId: row[2],
|
|
932
|
+
status: row[3],
|
|
933
|
+
expiresAt: row[4],
|
|
934
|
+
revokedAt: row[5],
|
|
935
|
+
createdAt: row[6],
|
|
936
|
+
updatedAt: row[7]
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
exports.getApplicationSessionQuery = `-- name: GetApplicationSession :one
|
|
940
|
+
SELECT
|
|
941
|
+
id,
|
|
942
|
+
user_id,
|
|
943
|
+
active_organization_id,
|
|
944
|
+
status,
|
|
945
|
+
expires_at,
|
|
946
|
+
revoked_at,
|
|
947
|
+
created_at,
|
|
948
|
+
updated_at
|
|
949
|
+
FROM weave.application_sessions
|
|
950
|
+
WHERE id = $1`;
|
|
951
|
+
async function getApplicationSession(client, args) {
|
|
952
|
+
const result = await client.query({
|
|
953
|
+
text: exports.getApplicationSessionQuery,
|
|
954
|
+
values: [args.id],
|
|
955
|
+
rowMode: "array"
|
|
956
|
+
});
|
|
957
|
+
if (result.rows.length !== 1) {
|
|
958
|
+
return null;
|
|
959
|
+
}
|
|
960
|
+
const row = result.rows[0];
|
|
961
|
+
return {
|
|
962
|
+
id: row[0],
|
|
963
|
+
userId: row[1],
|
|
964
|
+
activeOrganizationId: row[2],
|
|
965
|
+
status: row[3],
|
|
966
|
+
expiresAt: row[4],
|
|
967
|
+
revokedAt: row[5],
|
|
968
|
+
createdAt: row[6],
|
|
969
|
+
updatedAt: row[7]
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
exports.setApplicationSessionActiveOrganizationQuery = `-- name: SetApplicationSessionActiveOrganization :one
|
|
973
|
+
UPDATE weave.application_sessions
|
|
974
|
+
SET
|
|
975
|
+
active_organization_id = $1,
|
|
976
|
+
updated_at = now()
|
|
977
|
+
WHERE id = $2
|
|
978
|
+
AND status = 'active'
|
|
979
|
+
RETURNING
|
|
980
|
+
id,
|
|
981
|
+
user_id,
|
|
982
|
+
active_organization_id,
|
|
983
|
+
status,
|
|
984
|
+
expires_at,
|
|
985
|
+
revoked_at,
|
|
986
|
+
created_at,
|
|
987
|
+
updated_at`;
|
|
988
|
+
async function setApplicationSessionActiveOrganization(client, args) {
|
|
989
|
+
const result = await client.query({
|
|
990
|
+
text: exports.setApplicationSessionActiveOrganizationQuery,
|
|
991
|
+
values: [args.organizationId, args.id],
|
|
992
|
+
rowMode: "array"
|
|
993
|
+
});
|
|
994
|
+
if (result.rows.length !== 1) {
|
|
995
|
+
return null;
|
|
996
|
+
}
|
|
997
|
+
const row = result.rows[0];
|
|
998
|
+
return {
|
|
999
|
+
id: row[0],
|
|
1000
|
+
userId: row[1],
|
|
1001
|
+
activeOrganizationId: row[2],
|
|
1002
|
+
status: row[3],
|
|
1003
|
+
expiresAt: row[4],
|
|
1004
|
+
revokedAt: row[5],
|
|
1005
|
+
createdAt: row[6],
|
|
1006
|
+
updatedAt: row[7]
|
|
1007
|
+
};
|
|
1008
|
+
}
|
|
1009
|
+
exports.revokeApplicationSessionQuery = `-- name: RevokeApplicationSession :execrows
|
|
1010
|
+
UPDATE weave.application_sessions
|
|
1011
|
+
SET
|
|
1012
|
+
status = 'revoked',
|
|
1013
|
+
revoked_at = now(),
|
|
1014
|
+
updated_at = now()
|
|
1015
|
+
WHERE id = $1
|
|
1016
|
+
AND status = 'active'`;
|
|
1017
|
+
exports.upsertApplicationSessionOrganizationSessionQuery = `-- name: UpsertApplicationSessionOrganizationSession :one
|
|
1018
|
+
INSERT INTO weave.application_session_organization_sessions (
|
|
1019
|
+
application_session_id,
|
|
1020
|
+
organization_id,
|
|
1021
|
+
identity_link_id,
|
|
1022
|
+
stytch_organization_id,
|
|
1023
|
+
stytch_member_id,
|
|
1024
|
+
stytch_member_session_id,
|
|
1025
|
+
stytch_session_token_ciphertext,
|
|
1026
|
+
auth_state,
|
|
1027
|
+
expires_at,
|
|
1028
|
+
last_validated_at
|
|
1029
|
+
) VALUES (
|
|
1030
|
+
$1,
|
|
1031
|
+
$2,
|
|
1032
|
+
$3,
|
|
1033
|
+
$4,
|
|
1034
|
+
$5,
|
|
1035
|
+
$6,
|
|
1036
|
+
$7,
|
|
1037
|
+
$8,
|
|
1038
|
+
$9,
|
|
1039
|
+
$10
|
|
1040
|
+
)
|
|
1041
|
+
ON CONFLICT (application_session_id, organization_id) DO UPDATE
|
|
1042
|
+
SET
|
|
1043
|
+
identity_link_id = EXCLUDED.identity_link_id,
|
|
1044
|
+
stytch_organization_id = EXCLUDED.stytch_organization_id,
|
|
1045
|
+
stytch_member_id = EXCLUDED.stytch_member_id,
|
|
1046
|
+
stytch_member_session_id = EXCLUDED.stytch_member_session_id,
|
|
1047
|
+
stytch_session_token_ciphertext = EXCLUDED.stytch_session_token_ciphertext,
|
|
1048
|
+
auth_state = EXCLUDED.auth_state,
|
|
1049
|
+
expires_at = EXCLUDED.expires_at,
|
|
1050
|
+
last_validated_at = EXCLUDED.last_validated_at,
|
|
1051
|
+
updated_at = now()
|
|
1052
|
+
RETURNING
|
|
1053
|
+
id,
|
|
1054
|
+
application_session_id,
|
|
1055
|
+
organization_id,
|
|
1056
|
+
identity_link_id,
|
|
1057
|
+
stytch_organization_id,
|
|
1058
|
+
stytch_member_id,
|
|
1059
|
+
stytch_member_session_id,
|
|
1060
|
+
stytch_session_token_ciphertext,
|
|
1061
|
+
auth_state,
|
|
1062
|
+
expires_at,
|
|
1063
|
+
last_validated_at,
|
|
1064
|
+
created_at,
|
|
1065
|
+
updated_at`;
|
|
1066
|
+
async function upsertApplicationSessionOrganizationSession(client, args) {
|
|
1067
|
+
const result = await client.query({
|
|
1068
|
+
text: exports.upsertApplicationSessionOrganizationSessionQuery,
|
|
1069
|
+
values: [args.applicationSessionId, args.organizationId, args.identityLinkId, args.stytchOrganizationId, args.stytchMemberId, args.stytchMemberSessionId, args.stytchSessionTokenCiphertext, args.authState, args.expiresAt, args.lastValidatedAt],
|
|
1070
|
+
rowMode: "array"
|
|
1071
|
+
});
|
|
1072
|
+
if (result.rows.length !== 1) {
|
|
1073
|
+
return null;
|
|
1074
|
+
}
|
|
1075
|
+
const row = result.rows[0];
|
|
1076
|
+
return {
|
|
1077
|
+
id: row[0],
|
|
1078
|
+
applicationSessionId: row[1],
|
|
1079
|
+
organizationId: row[2],
|
|
1080
|
+
identityLinkId: row[3],
|
|
1081
|
+
stytchOrganizationId: row[4],
|
|
1082
|
+
stytchMemberId: row[5],
|
|
1083
|
+
stytchMemberSessionId: row[6],
|
|
1084
|
+
stytchSessionTokenCiphertext: row[7],
|
|
1085
|
+
authState: row[8],
|
|
1086
|
+
expiresAt: row[9],
|
|
1087
|
+
lastValidatedAt: row[10],
|
|
1088
|
+
createdAt: row[11],
|
|
1089
|
+
updatedAt: row[12]
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
exports.getApplicationSessionOrganizationSessionQuery = `-- name: GetApplicationSessionOrganizationSession :one
|
|
1093
|
+
SELECT
|
|
1094
|
+
id,
|
|
1095
|
+
application_session_id,
|
|
1096
|
+
organization_id,
|
|
1097
|
+
identity_link_id,
|
|
1098
|
+
stytch_organization_id,
|
|
1099
|
+
stytch_member_id,
|
|
1100
|
+
stytch_member_session_id,
|
|
1101
|
+
stytch_session_token_ciphertext,
|
|
1102
|
+
auth_state,
|
|
1103
|
+
expires_at,
|
|
1104
|
+
last_validated_at,
|
|
1105
|
+
created_at,
|
|
1106
|
+
updated_at
|
|
1107
|
+
FROM weave.application_session_organization_sessions
|
|
1108
|
+
WHERE application_session_id = $1
|
|
1109
|
+
AND organization_id = $2`;
|
|
1110
|
+
async function getApplicationSessionOrganizationSession(client, args) {
|
|
1111
|
+
const result = await client.query({
|
|
1112
|
+
text: exports.getApplicationSessionOrganizationSessionQuery,
|
|
1113
|
+
values: [args.applicationSessionId, args.organizationId],
|
|
1114
|
+
rowMode: "array"
|
|
1115
|
+
});
|
|
1116
|
+
if (result.rows.length !== 1) {
|
|
1117
|
+
return null;
|
|
1118
|
+
}
|
|
1119
|
+
const row = result.rows[0];
|
|
1120
|
+
return {
|
|
1121
|
+
id: row[0],
|
|
1122
|
+
applicationSessionId: row[1],
|
|
1123
|
+
organizationId: row[2],
|
|
1124
|
+
identityLinkId: row[3],
|
|
1125
|
+
stytchOrganizationId: row[4],
|
|
1126
|
+
stytchMemberId: row[5],
|
|
1127
|
+
stytchMemberSessionId: row[6],
|
|
1128
|
+
stytchSessionTokenCiphertext: row[7],
|
|
1129
|
+
authState: row[8],
|
|
1130
|
+
expiresAt: row[9],
|
|
1131
|
+
lastValidatedAt: row[10],
|
|
1132
|
+
createdAt: row[11],
|
|
1133
|
+
updatedAt: row[12]
|
|
1134
|
+
};
|
|
1135
|
+
}
|
|
1136
|
+
exports.listApplicationSessionOrganizationSessionStatesQuery = `-- name: ListApplicationSessionOrganizationSessionStates :many
|
|
1137
|
+
SELECT
|
|
1138
|
+
s.id,
|
|
1139
|
+
s.application_session_id,
|
|
1140
|
+
s.organization_id,
|
|
1141
|
+
o.slug AS organization_slug,
|
|
1142
|
+
o.name AS organization_name,
|
|
1143
|
+
s.identity_link_id,
|
|
1144
|
+
s.stytch_organization_id,
|
|
1145
|
+
s.stytch_member_id,
|
|
1146
|
+
s.stytch_member_session_id,
|
|
1147
|
+
s.auth_state,
|
|
1148
|
+
s.expires_at,
|
|
1149
|
+
s.last_validated_at,
|
|
1150
|
+
s.created_at,
|
|
1151
|
+
s.updated_at
|
|
1152
|
+
FROM weave.application_session_organization_sessions AS s
|
|
1153
|
+
JOIN weave.organizations AS o
|
|
1154
|
+
ON o.id = s.organization_id
|
|
1155
|
+
WHERE s.application_session_id = $1
|
|
1156
|
+
ORDER BY o.slug ASC`;
|
|
1157
|
+
async function listApplicationSessionOrganizationSessionStates(client, args) {
|
|
1158
|
+
const result = await client.query({
|
|
1159
|
+
text: exports.listApplicationSessionOrganizationSessionStatesQuery,
|
|
1160
|
+
values: [args.applicationSessionId],
|
|
1161
|
+
rowMode: "array"
|
|
1162
|
+
});
|
|
1163
|
+
return result.rows.map(row => {
|
|
1164
|
+
return {
|
|
1165
|
+
id: row[0],
|
|
1166
|
+
applicationSessionId: row[1],
|
|
1167
|
+
organizationId: row[2],
|
|
1168
|
+
organizationSlug: row[3],
|
|
1169
|
+
organizationName: row[4],
|
|
1170
|
+
identityLinkId: row[5],
|
|
1171
|
+
stytchOrganizationId: row[6],
|
|
1172
|
+
stytchMemberId: row[7],
|
|
1173
|
+
stytchMemberSessionId: row[8],
|
|
1174
|
+
authState: row[9],
|
|
1175
|
+
expiresAt: row[10],
|
|
1176
|
+
lastValidatedAt: row[11],
|
|
1177
|
+
createdAt: row[12],
|
|
1178
|
+
updatedAt: row[13]
|
|
1179
|
+
};
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
exports.markApplicationSessionOrganizationSessionStateQuery = `-- name: MarkApplicationSessionOrganizationSessionState :one
|
|
1183
|
+
UPDATE weave.application_session_organization_sessions
|
|
1184
|
+
SET
|
|
1185
|
+
auth_state = $1,
|
|
1186
|
+
last_validated_at = now(),
|
|
1187
|
+
updated_at = now()
|
|
1188
|
+
WHERE application_session_id = $2
|
|
1189
|
+
AND organization_id = $3
|
|
1190
|
+
RETURNING
|
|
1191
|
+
id,
|
|
1192
|
+
application_session_id,
|
|
1193
|
+
organization_id,
|
|
1194
|
+
identity_link_id,
|
|
1195
|
+
stytch_organization_id,
|
|
1196
|
+
stytch_member_id,
|
|
1197
|
+
stytch_member_session_id,
|
|
1198
|
+
stytch_session_token_ciphertext,
|
|
1199
|
+
auth_state,
|
|
1200
|
+
expires_at,
|
|
1201
|
+
last_validated_at,
|
|
1202
|
+
created_at,
|
|
1203
|
+
updated_at`;
|
|
1204
|
+
async function markApplicationSessionOrganizationSessionState(client, args) {
|
|
1205
|
+
const result = await client.query({
|
|
1206
|
+
text: exports.markApplicationSessionOrganizationSessionStateQuery,
|
|
1207
|
+
values: [args.authState, args.applicationSessionId, args.organizationId],
|
|
1208
|
+
rowMode: "array"
|
|
1209
|
+
});
|
|
1210
|
+
if (result.rows.length !== 1) {
|
|
1211
|
+
return null;
|
|
1212
|
+
}
|
|
1213
|
+
const row = result.rows[0];
|
|
1214
|
+
return {
|
|
1215
|
+
id: row[0],
|
|
1216
|
+
applicationSessionId: row[1],
|
|
1217
|
+
organizationId: row[2],
|
|
1218
|
+
identityLinkId: row[3],
|
|
1219
|
+
stytchOrganizationId: row[4],
|
|
1220
|
+
stytchMemberId: row[5],
|
|
1221
|
+
stytchMemberSessionId: row[6],
|
|
1222
|
+
stytchSessionTokenCiphertext: row[7],
|
|
1223
|
+
authState: row[8],
|
|
1224
|
+
expiresAt: row[9],
|
|
1225
|
+
lastValidatedAt: row[10],
|
|
1226
|
+
createdAt: row[11],
|
|
1227
|
+
updatedAt: row[12]
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
exports.deleteExpiredApplicationSessionsQuery = `-- name: DeleteExpiredApplicationSessions :execrows
|
|
1231
|
+
DELETE FROM weave.application_sessions
|
|
1232
|
+
WHERE expires_at <= now()
|
|
1233
|
+
OR status IN ('revoked', 'expired')`;
|