@jsb188/app 1.1.11 → 1.1.13
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/LICENSE +21 -0
- package/package.json +17 -6
- package/src/constants/agent.ts +44 -57
- package/src/constants/app.ts +43 -0
- package/src/constants/wsActions.ts +1 -15
- package/src/i18n/account.ts +1 -1
- package/src/i18n/agent.ts +321 -96
- package/src/i18n/agentToolBusiness.ts +340 -0
- package/src/i18n/agentToolGrid.ts +121 -0
- package/src/i18n/agentToolWorkflow.ts +101 -0
- package/src/i18n/agent_note.ts +110 -0
- package/src/i18n/app.ts +23 -17
- package/src/i18n/auth.ts +25 -30
- package/src/i18n/billing.ts +3 -85
- package/src/i18n/c.ts +953 -0
- package/src/i18n/campaign.ts +164 -211
- package/src/i18n/datetime.ts +6 -0
- package/src/i18n/editor.ts +56 -0
- package/src/i18n/email_outreach_editor.ts +526 -0
- package/src/i18n/error.ts +430 -202
- package/src/i18n/field_doc_editor.ts +21 -0
- package/src/i18n/field_doc_programs.ts +51 -0
- package/src/i18n/field_docs.ts +171 -8
- package/src/i18n/form.ts +7 -491
- package/src/i18n/index.ts +23 -3
- package/src/i18n/log.ts +234 -39
- package/src/i18n/memory.ts +18 -5
- package/src/i18n/message.ts +1 -0
- package/src/i18n/note.ts +5 -3
- package/src/i18n/org.ts +97 -45
- package/src/i18n/schedule.ts +133 -0
- package/src/i18n/sheet.ts +105 -161
- package/src/i18n/sheet_formula.ts +165 -0
- package/src/i18n/workflow.ts +112 -11
- package/src/main.ts +2 -2
- package/src/platform.ts +89 -49
- package/src/types/ai.d.ts +16 -1
- package/src/types/app.d.ts +29 -73
- package/src/types/auth.d.ts +1 -1
- package/src/types/other.d.ts +8 -1
- package/src/utils/api.ts +60 -10
- package/src/utils/clientIP.ts +213 -0
- package/src/utils/color.ts +95 -0
- package/src/utils/csv.ts +19 -0
- package/src/utils/datetime.ts +207 -31
- package/src/utils/deferredSave.ts +89 -0
- package/src/utils/email.ts +50 -0
- package/src/utils/expression.helpers.ts +470 -0
- package/src/utils/expression.ts +1633 -239
- package/src/utils/language.ts +9 -0
- package/src/utils/logic.ts +9 -162
- package/src/utils/number.ts +30 -11
- package/src/utils/object.ts +69 -127
- package/src/utils/promise.ts +78 -7
- package/src/utils/queryReset.ts +110 -61
- package/src/utils/string.ts +80 -143
- package/src/utils/url_client.ts +115 -15
- package/src/constants/billing.ts +0 -146
- package/src/i18n/agentDoc.ts +0 -110
- package/src/types/form.d.ts +0 -101
- package/src/utils/billing.ts +0 -141
- package/src/utils/managedSessionBff.test.ts +0 -60
- package/src/utils/string.test.ts +0 -293
- package/tsconfig.json +0 -12
package/src/constants/billing.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
export const PLATFORM_PRODUCT_ENUMS = [
|
|
2
|
-
// Subscriptions
|
|
3
|
-
'perks',
|
|
4
|
-
'kajiwoto_plus',
|
|
5
|
-
'kajiwoto_plus_yearly',
|
|
6
|
-
'kajiwoto_pro',
|
|
7
|
-
'kajiwoto_pro_yearly',
|
|
8
|
-
|
|
9
|
-
// These are for future proofing; don't use these until they're in the database
|
|
10
|
-
'big_planet_plus',
|
|
11
|
-
'big_planet_plus_yearly',
|
|
12
|
-
'big_planet_pro',
|
|
13
|
-
'big_planet_pro_yearly',
|
|
14
|
-
|
|
15
|
-
// Consumables
|
|
16
|
-
'coins_10',
|
|
17
|
-
'coins_20',
|
|
18
|
-
'coins_100',
|
|
19
|
-
|
|
20
|
-
// Expired
|
|
21
|
-
'kajiwoto_creator',
|
|
22
|
-
'creator_dataset_sub',
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
export const SUBSCRIPTION_CATALOG = [
|
|
26
|
-
// [groupName, stripeProductId, stripePriceId]
|
|
27
|
-
['PLUS', 'prod_H0WgTKq5qiK51Q', 'plan_H0WhZdwYcq9Fn7'],
|
|
28
|
-
['PRO', 'prod_H0WgTKq5qiK51Q', 'price_1MkLqjJI6Kvu2OvUPzFwwncH'],
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
export const SUBSCRIPTION_CATALOG_TEST = [
|
|
32
|
-
// [groupName, stripeProductId, stripePriceId]
|
|
33
|
-
['PLUS', 'prod_O2uOYfarTaRqJX', 'price_1QBox9JI6Kvu2OvUoy9vBmKL'],
|
|
34
|
-
['PRO', 'prod_O2uOYfarTaRqJX', 'price_1QBox9JI6Kvu2OvUQ86KgX5C'],
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
export const PRICE_ID_TO_PRODUCT = {
|
|
38
|
-
plan_H0WhZdwYcq9Fn7: {
|
|
39
|
-
name: 'kajiwoto_plus',
|
|
40
|
-
group: 'PLUS',
|
|
41
|
-
},
|
|
42
|
-
price_1HmqX5JI6Kvu2OvUM1edHUMw: {
|
|
43
|
-
name: 'kajiwoto_plus_yearly',
|
|
44
|
-
group: 'PLUS',
|
|
45
|
-
},
|
|
46
|
-
price_1MkLqjJI6Kvu2OvUPzFwwncH: {
|
|
47
|
-
name: 'kajiwoto_pro',
|
|
48
|
-
group: 'PRO',
|
|
49
|
-
},
|
|
50
|
-
price_1MkLrzJI6Kvu2OvUMPyWvKdt: {
|
|
51
|
-
name: 'kajiwoto_pro_yearly',
|
|
52
|
-
group: 'PRO',
|
|
53
|
-
},
|
|
54
|
-
price_1IOudjJI6Kvu2OvU6znCc2oZ: {
|
|
55
|
-
name: 'coins_10',
|
|
56
|
-
group: 'COINS',
|
|
57
|
-
},
|
|
58
|
-
price_1IOudjJI6Kvu2OvUnRFoUQUm: {
|
|
59
|
-
name: 'coins_20',
|
|
60
|
-
group: 'COINS',
|
|
61
|
-
},
|
|
62
|
-
price_1K3y6EJI6Kvu2OvUYUDJgMy6: {
|
|
63
|
-
name: 'coins_100',
|
|
64
|
-
group: 'COINS',
|
|
65
|
-
},
|
|
66
|
-
// price_HNzF3cC8hMxs0Q: 'kajiwoto_creator',
|
|
67
|
-
// plan_HIXtNYWIEx9eST: 'creator_dataset_sub',
|
|
68
|
-
} as {
|
|
69
|
-
[key: string]: {
|
|
70
|
-
name: string;
|
|
71
|
-
group: string;
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const PRICE_ID_TO_PRODUCT_TEST = {
|
|
76
|
-
price_1QBox9JI6Kvu2OvUoy9vBmKL: {
|
|
77
|
-
name: 'kajiwoto_plus',
|
|
78
|
-
group: 'PLUS',
|
|
79
|
-
},
|
|
80
|
-
price_1QBox9JI6Kvu2OvU7bKCLUYq: {
|
|
81
|
-
name: 'kajiwoto_plus_yearly',
|
|
82
|
-
group: 'PLUS',
|
|
83
|
-
},
|
|
84
|
-
price_1QBox9JI6Kvu2OvUQ86KgX5C: {
|
|
85
|
-
name: 'kajiwoto_pro',
|
|
86
|
-
group: 'PRO',
|
|
87
|
-
},
|
|
88
|
-
price_1QBox9JI6Kvu2OvU8Fn4ftXb: {
|
|
89
|
-
name: 'kajiwoto_pro_yearly',
|
|
90
|
-
group: 'PRO',
|
|
91
|
-
},
|
|
92
|
-
price_1NGnmKJI6Kvu2OvUx3bykj0F: {
|
|
93
|
-
name: 'coins_10',
|
|
94
|
-
group: 'COINS',
|
|
95
|
-
},
|
|
96
|
-
price_1NGoBHJI6Kvu2OvUONbOujKG: {
|
|
97
|
-
name: 'coins_20',
|
|
98
|
-
group: 'COINS',
|
|
99
|
-
},
|
|
100
|
-
price_1NGoAjJI6Kvu2OvUSRWartW3: {
|
|
101
|
-
name: 'coins_100',
|
|
102
|
-
group: 'COINS',
|
|
103
|
-
},
|
|
104
|
-
// price_HNzJjKRMAhEakr: 'kajiwoto_creator',
|
|
105
|
-
// plan_HIYFVZvX8lLTol: 'creator_dataset_sub',
|
|
106
|
-
} as {
|
|
107
|
-
[key: string]: {
|
|
108
|
-
name: string;
|
|
109
|
-
group: string;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// Products
|
|
114
|
-
// export const PRICES = {
|
|
115
|
-
// kajiwoto_plus: 7.99,
|
|
116
|
-
// kajiwoto_plus_yearly: 87.89,
|
|
117
|
-
// kajiwoto_pro: 29.99,
|
|
118
|
-
// kajiwoto_pro_yearly: 299.99,
|
|
119
|
-
// coins_10: 9.99,
|
|
120
|
-
// coins_20: 19.98,
|
|
121
|
-
// coins_100: 99.90,
|
|
122
|
-
|
|
123
|
-
// // Skin Prices
|
|
124
|
-
// SKIN_PRICE_1: 2.99,
|
|
125
|
-
// SKIN_PRICE_2: 4.99,
|
|
126
|
-
// SKIN_PRICE_3: 9.99,
|
|
127
|
-
// SKIN_PRICE_4: 19.99
|
|
128
|
-
// };
|
|
129
|
-
|
|
130
|
-
// export const SUBSCRIPTION_PRODUCTS = [
|
|
131
|
-
// 'kajiwoto_plus',
|
|
132
|
-
// 'kajiwoto_plus_yearly',
|
|
133
|
-
// 'kajiwoto_pro',
|
|
134
|
-
// 'kajiwoto_pro_yearly',
|
|
135
|
-
// 'kajiwoto_creator',
|
|
136
|
-
// 'kplus_test'
|
|
137
|
-
// ];
|
|
138
|
-
|
|
139
|
-
// export const HAS_PLUS_SUB_TYPES = [
|
|
140
|
-
// 'plus',
|
|
141
|
-
// 'pro'
|
|
142
|
-
// ];
|
|
143
|
-
|
|
144
|
-
// export const HAS_PRO_SUB_TYPES = [
|
|
145
|
-
// 'pro'
|
|
146
|
-
// ];
|
package/src/i18n/agentDoc.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
en: {
|
|
3
|
-
access_settings: 'Access settings',
|
|
4
|
-
access_settings_msg: 'Choose who can view and edit this document.',
|
|
5
|
-
access_level_team: 'Team',
|
|
6
|
-
access_team_members: 'Team members',
|
|
7
|
-
access_network_orgs: 'Network organizations',
|
|
8
|
-
access_no_team_members_found: 'No team members found.',
|
|
9
|
-
access_no_network_orgs_found: 'No network organizations found.',
|
|
10
|
-
access_can_view: 'Can view',
|
|
11
|
-
access_can_edit: 'Can edit',
|
|
12
|
-
access_no_access: 'No access',
|
|
13
|
-
access_general_title: 'General access',
|
|
14
|
-
access_only_invites: 'Only with invites',
|
|
15
|
-
access_anyone_with_link: 'Anyone with link',
|
|
16
|
-
access_admin_owner_msg: 'Admins/Owners always have full access.',
|
|
17
|
-
access_copy_link: 'Copy link',
|
|
18
|
-
access_link_copied: 'Link copied!',
|
|
19
|
-
access_custom_member_permission_msg:
|
|
20
|
-
'There is [cl_primary##%{membersCount} custom member] permission.',
|
|
21
|
-
access_custom_member_permissions_msg:
|
|
22
|
-
'There are [cl_primary##%{membersCount} custom member] permissions.',
|
|
23
|
-
access_custom_member_permission_org_permission_msg:
|
|
24
|
-
'There are [cl_primary##%{membersCount} custom member] permission and [cl_primary##%{orgsCount} custom network] permission.',
|
|
25
|
-
access_custom_member_permission_org_permissions_msg:
|
|
26
|
-
'There are [cl_primary##%{membersCount} custom member] permission and [cl_primary##%{orgsCount} custom network] permissions.',
|
|
27
|
-
access_custom_member_permissions_org_permission_msg:
|
|
28
|
-
'There are [cl_primary##%{membersCount} custom member] permissions and [cl_primary##%{orgsCount} custom network] permission.',
|
|
29
|
-
access_custom_member_permissions_org_permissions_msg:
|
|
30
|
-
'There are [cl_primary##%{membersCount} custom member] permissions and [cl_primary##%{orgsCount} custom network] permissions.',
|
|
31
|
-
access_custom_org_permission_msg:
|
|
32
|
-
'There is [cl_primary##%{orgsCount} custom network] permission.',
|
|
33
|
-
access_custom_org_permissions_msg:
|
|
34
|
-
'There are [cl_primary##%{orgsCount} custom network] permissions.',
|
|
35
|
-
access_anyone_with_link_msg: 'Anyone with the link can view.',
|
|
36
|
-
access_network_view_msg: 'Other network organizations can view.',
|
|
37
|
-
access_network_edit_msg: 'Other network organizations can view and edit.',
|
|
38
|
-
access_only_invites_msg: 'Invites are required to gain access.',
|
|
39
|
-
access_team_view_msg: 'Your team can view by default, but not edit.',
|
|
40
|
-
access_team_edit_msg: 'Your team can view and edit by default.',
|
|
41
|
-
access_team_none_msg: 'Your team cannot view unless they were invited.',
|
|
42
|
-
|
|
43
|
-
// Agent doc page
|
|
44
|
-
|
|
45
|
-
login_change_required_msg:
|
|
46
|
-
"This document doesn't belong to [em_text##%{orgName}].\n Change your login to access this document.",
|
|
47
|
-
agent_doc_missing: 'Document is missing',
|
|
48
|
-
agent_doc_missing_msg:
|
|
49
|
-
'The document you are looking for could not be found.',
|
|
50
|
-
agent_docs: 'Agent docs',
|
|
51
|
-
agent_docs_desc:
|
|
52
|
-
'Documents your AI agents read to understand your organization.',
|
|
53
|
-
agent_docs_empty_msg: 'No documents have been created yet.',
|
|
54
|
-
untitled: 'Untitled',
|
|
55
|
-
new_doc: 'New document',
|
|
56
|
-
last_edited: 'Last edited',
|
|
57
|
-
ai_status: 'AI status',
|
|
58
|
-
delete_doc: 'Delete document',
|
|
59
|
-
delete_doc_confirm_msg:
|
|
60
|
-
'Move this document to the trash? It will be permanently deleted after 90 days.',
|
|
61
|
-
delete_doc_no_access_msg:
|
|
62
|
-
'You do not have permission to delete documents in this organization.',
|
|
63
|
-
|
|
64
|
-
// Folders
|
|
65
|
-
|
|
66
|
-
folder: 'Folder',
|
|
67
|
-
folders: 'Folders',
|
|
68
|
-
folders_msg:
|
|
69
|
-
'Folders group documents so people and AI agents can find them by topic.',
|
|
70
|
-
all_docs: 'All documents',
|
|
71
|
-
no_folder: 'No folder',
|
|
72
|
-
new_folder: 'New folder',
|
|
73
|
-
rename_folder: 'Rename folder',
|
|
74
|
-
delete_folder: 'Delete folder',
|
|
75
|
-
delete_folder_confirm_msg:
|
|
76
|
-
'Delete this folder? Documents inside are kept and moved out of the folder.',
|
|
77
|
-
folder_name: 'Folder name',
|
|
78
|
-
folder_name_taken_msg: 'A folder with this name already exists.',
|
|
79
|
-
move_to_folder: 'Move to folder',
|
|
80
|
-
|
|
81
|
-
// AI settings
|
|
82
|
-
|
|
83
|
-
ai_settings: 'AI settings',
|
|
84
|
-
ai_settings_msg: 'Control how AI agents use this document.',
|
|
85
|
-
ai_cannot_read: 'Hide from AI',
|
|
86
|
-
ai_cannot_read_msg: 'AI agents cannot see or read this document.',
|
|
87
|
-
ai_cannot_edit: 'Lock from AI edits',
|
|
88
|
-
ai_cannot_edit_msg: 'AI agents can read this document but never modify it.',
|
|
89
|
-
ai_pinned: 'Pin for AI',
|
|
90
|
-
ai_pinned_msg:
|
|
91
|
-
'Always include this document in AI agent instructions, instead of on-demand lookup.',
|
|
92
|
-
ai_hidden_surfaces: 'Hide from specific agents',
|
|
93
|
-
ai_hidden_surfaces_msg:
|
|
94
|
-
'This document stays visible to every other agent type.',
|
|
95
|
-
ai_review_by: 'Review by',
|
|
96
|
-
ai_review_by_msg:
|
|
97
|
-
'After this date, agents treat the document as possibly outdated.',
|
|
98
|
-
ai_surface_chat: 'Chat assistant',
|
|
99
|
-
ai_surface_runner: 'Automation runners',
|
|
100
|
-
ai_surface_postmaster: 'Email inbox agent',
|
|
101
|
-
ai_surface_analyst: 'Analyst',
|
|
102
|
-
|
|
103
|
-
// Badges
|
|
104
|
-
|
|
105
|
-
badge_ai_hidden: 'AI hidden',
|
|
106
|
-
badge_ai_locked: 'AI locked',
|
|
107
|
-
badge_pinned: 'Pinned',
|
|
108
|
-
badge_stale: 'Needs review',
|
|
109
|
-
},
|
|
110
|
-
};
|
package/src/types/form.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import type { ChangeEvent, FormEvent, KeyboardEvent, MouseEvent } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Types; form schema
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export type FormValuesObj = {
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
__errorFields?: string[];
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type FormValueSetter<TFormValues extends FormValuesObj = any> = (
|
|
13
|
-
values: TFormValues | ((prev: TFormValues) => TFormValues),
|
|
14
|
-
) => void;
|
|
15
|
-
|
|
16
|
-
export type FormItemType =
|
|
17
|
-
| 'subtitle'
|
|
18
|
-
| 'break'
|
|
19
|
-
| 'group'
|
|
20
|
-
| 'input'
|
|
21
|
-
| 'section_title'
|
|
22
|
-
| 'input_click'
|
|
23
|
-
| 'input_w_button'
|
|
24
|
-
| 'input_time_from_date'
|
|
25
|
-
| 'password'
|
|
26
|
-
| 'textarea'
|
|
27
|
-
| 'none'
|
|
28
|
-
| (string & {});
|
|
29
|
-
|
|
30
|
-
interface SchemaItemAny<TCurrentData = any, TDataForSchema = any> {
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
__typename?: string;
|
|
33
|
-
setter?: (currentData?: TCurrentData, dataForSchema?: TDataForSchema) => any;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface FormItemSchemaObj<TCurrentData = any, TDataForSchema = any> {
|
|
37
|
-
__type: FormItemType;
|
|
38
|
-
autoFocus?: boolean;
|
|
39
|
-
disabled?: boolean;
|
|
40
|
-
hidden?: boolean | ((dataForSchema: TDataForSchema) => boolean);
|
|
41
|
-
locked?: boolean | ((dataForSchema: TDataForSchema) => boolean);
|
|
42
|
-
labelClassName?: string;
|
|
43
|
-
listenToInput?: boolean;
|
|
44
|
-
value?: any;
|
|
45
|
-
item: SchemaItemAny<TCurrentData, TDataForSchema>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface SchemaRule<TFormValues extends FormValuesObj = any> {
|
|
49
|
-
for: string;
|
|
50
|
-
rule: (value: any, formValues: TFormValues) => boolean;
|
|
51
|
-
error: any;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface FormSchemaObj<
|
|
55
|
-
TFormValues extends FormValuesObj = any,
|
|
56
|
-
TCurrentData = any,
|
|
57
|
-
TDataForSchema = any,
|
|
58
|
-
> {
|
|
59
|
-
listData: FormItemSchemaObj<TCurrentData, TDataForSchema>[];
|
|
60
|
-
rules?: SchemaRule<TFormValues>[];
|
|
61
|
-
isButtonDisabled?: (formValues: TFormValues) => boolean;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Types; form items
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
interface FormGroupType<
|
|
69
|
-
TFormValues extends FormValuesObj = any,
|
|
70
|
-
TCurrentData = any,
|
|
71
|
-
TDataForSchema = any,
|
|
72
|
-
> {
|
|
73
|
-
id?: string;
|
|
74
|
-
name: string;
|
|
75
|
-
label?: string;
|
|
76
|
-
value: string | number | null;
|
|
77
|
-
items: Array<FormItemIfaceObj<TFormValues, TCurrentData, TDataForSchema>>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface FormItemIfaceObj<
|
|
81
|
-
TFormValues extends FormValuesObj = any,
|
|
82
|
-
TCurrentData = any,
|
|
83
|
-
TDataForSchema = any,
|
|
84
|
-
> extends FormItemSchemaObj<TCurrentData, TDataForSchema> {
|
|
85
|
-
name: string;
|
|
86
|
-
preset?: string;
|
|
87
|
-
className?: string;
|
|
88
|
-
inputClassName?: string;
|
|
89
|
-
focusStyle?: string;
|
|
90
|
-
hidden?: boolean | ((dataForSchema: TDataForSchema) => boolean);
|
|
91
|
-
locked?: boolean | ((dataForSchema: TDataForSchema) => boolean);
|
|
92
|
-
formValues: TFormValues;
|
|
93
|
-
setFormValues: FormValueSetter<TFormValues>;
|
|
94
|
-
onInput?: (e: FormEvent, name: string) => void;
|
|
95
|
-
onKeyDown?: (e: KeyboardEvent, name: string) => void;
|
|
96
|
-
onSubmit?: (e: MouseEvent, name: string) => void;
|
|
97
|
-
onChange?: (
|
|
98
|
-
e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
|
|
99
|
-
name: string,
|
|
100
|
-
) => void;
|
|
101
|
-
}
|
package/src/utils/billing.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SUBSCRIPTION_CATALOG,
|
|
3
|
-
SUBSCRIPTION_CATALOG_TEST,
|
|
4
|
-
} from '../constants/billing.ts';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Types
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
type SubscriptionCatalogItem = {
|
|
11
|
-
group: string;
|
|
12
|
-
notReady: boolean;
|
|
13
|
-
priceLabel: string | null;
|
|
14
|
-
startingPrice: number;
|
|
15
|
-
currency: string;
|
|
16
|
-
recurringInterval: string;
|
|
17
|
-
recurringIntervalCount: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type SubscriptionPricingOption = {
|
|
21
|
-
id: string;
|
|
22
|
-
group: string;
|
|
23
|
-
notReady: boolean;
|
|
24
|
-
priceLabel: string;
|
|
25
|
-
price: number;
|
|
26
|
-
currency: string;
|
|
27
|
-
recurringInterval: string;
|
|
28
|
-
recurringIntervalCount: number;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get development or production catalog
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
function getSubscriptionCatalog(isDev = false) {
|
|
36
|
-
return isDev ? SUBSCRIPTION_CATALOG_TEST : SUBSCRIPTION_CATALOG;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get list of subscription catalogs
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
export function getPlatformSubscriptionCatalog(
|
|
44
|
-
platformProducts?: any[],
|
|
45
|
-
isDev?: boolean,
|
|
46
|
-
): SubscriptionCatalogItem[] {
|
|
47
|
-
return getSubscriptionCatalog(isDev).map((sub) => {
|
|
48
|
-
const [groupName, stripeProductId, stripePriceId] = sub;
|
|
49
|
-
const product = platformProducts?.find(
|
|
50
|
-
(pr: any) => pr.id === stripeProductId,
|
|
51
|
-
);
|
|
52
|
-
const startingPrice = product?.prices?.find(
|
|
53
|
-
(pc: any) => pc.id === stripePriceId,
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
if (!startingPrice) {
|
|
57
|
-
// Data is not ready; or the Stripe API Key used by the server is _not_ the live key
|
|
58
|
-
return {
|
|
59
|
-
group: groupName,
|
|
60
|
-
notReady: true,
|
|
61
|
-
priceLabel: null,
|
|
62
|
-
startingPrice: 0,
|
|
63
|
-
currency: 'USD',
|
|
64
|
-
recurringInterval: 'month',
|
|
65
|
-
recurringIntervalCount: 1,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Add locale here later
|
|
70
|
-
const locale = undefined;
|
|
71
|
-
|
|
72
|
-
const priceLabel = (startingPrice.unitAmount / 100).toLocaleString(locale, {
|
|
73
|
-
style: 'currency',
|
|
74
|
-
currency: startingPrice.currency,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
group: groupName,
|
|
79
|
-
notReady: false,
|
|
80
|
-
priceLabel,
|
|
81
|
-
startingPrice: startingPrice.unitAmount,
|
|
82
|
-
currency: startingPrice.currency,
|
|
83
|
-
recurringInterval: startingPrice.recurringInterval,
|
|
84
|
-
recurringIntervalCount: startingPrice.recurringIntervalCount,
|
|
85
|
-
};
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Get list of subscription options for each tier
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
export function getPlatformSubscriptionPricingOptions(
|
|
94
|
-
platformProducts?: any[],
|
|
95
|
-
subGroup?: 'PERKS' | 'PLUS' | 'PRO' | 'COINS',
|
|
96
|
-
isDev?: boolean,
|
|
97
|
-
): SubscriptionPricingOption[] {
|
|
98
|
-
const catalogItem = getSubscriptionCatalog(isDev).find(
|
|
99
|
-
(item: any) => item[0] === subGroup,
|
|
100
|
-
);
|
|
101
|
-
if (!catalogItem) {
|
|
102
|
-
console.warn('Unknown subscription group: ' + subGroup);
|
|
103
|
-
return [];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const [, stripeProductId] = catalogItem;
|
|
107
|
-
const product = platformProducts?.find(
|
|
108
|
-
(pr: any) => pr.id === stripeProductId,
|
|
109
|
-
);
|
|
110
|
-
if (!product) {
|
|
111
|
-
if (platformProducts) {
|
|
112
|
-
console.warn('Platform product not found for: ' + stripeProductId);
|
|
113
|
-
}
|
|
114
|
-
return [];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const pricingList = product.prices
|
|
118
|
-
.filter((pc: any) => pc.productGroup === subGroup)
|
|
119
|
-
.sort((pc: any) => (pc.recurringInterval === 'year' ? -1 : 1));
|
|
120
|
-
|
|
121
|
-
return pricingList.map((pc: any) => {
|
|
122
|
-
// Add locale here later
|
|
123
|
-
const locale = undefined;
|
|
124
|
-
|
|
125
|
-
const priceLabel = (pc.unitAmount / 100).toLocaleString(locale, {
|
|
126
|
-
style: 'currency',
|
|
127
|
-
currency: pc.currency,
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
id: pc.id,
|
|
132
|
-
group: pc.productGroup,
|
|
133
|
-
notReady: false,
|
|
134
|
-
priceLabel,
|
|
135
|
-
price: pc.unitAmount,
|
|
136
|
-
currency: pc.currency,
|
|
137
|
-
recurringInterval: pc.recurringInterval,
|
|
138
|
-
recurringIntervalCount: pc.recurringIntervalCount,
|
|
139
|
-
};
|
|
140
|
-
});
|
|
141
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
createManagedSessionBffProof,
|
|
5
|
-
verifyManagedSessionBffProof,
|
|
6
|
-
} from './managedSessionBff.ts';
|
|
7
|
-
|
|
8
|
-
const TEST_TIMESTAMP = 1_720_000_000_000;
|
|
9
|
-
const TEST_NONCE = '8c7535fc-1b8c-4ac6-b7f5-60b47ec83c3f';
|
|
10
|
-
|
|
11
|
-
describe('managed session BFF proof', () => {
|
|
12
|
-
it('accepts an authentic proof only inside its short validity window', async () => {
|
|
13
|
-
const proof = await createManagedSessionBffProof(
|
|
14
|
-
'deployment-secret',
|
|
15
|
-
TEST_TIMESTAMP,
|
|
16
|
-
TEST_NONCE,
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
expect(
|
|
20
|
-
await verifyManagedSessionBffProof(
|
|
21
|
-
proof,
|
|
22
|
-
'deployment-secret',
|
|
23
|
-
TEST_TIMESTAMP + 30_000,
|
|
24
|
-
),
|
|
25
|
-
).toBe(true);
|
|
26
|
-
expect(
|
|
27
|
-
await verifyManagedSessionBffProof(
|
|
28
|
-
proof,
|
|
29
|
-
'deployment-secret',
|
|
30
|
-
TEST_TIMESTAMP + 30_001,
|
|
31
|
-
),
|
|
32
|
-
).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('rejects missing, forged, and differently scoped proofs', async () => {
|
|
36
|
-
const proof = await createManagedSessionBffProof(
|
|
37
|
-
'deployment-secret',
|
|
38
|
-
TEST_TIMESTAMP,
|
|
39
|
-
TEST_NONCE,
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
expect(await verifyManagedSessionBffProof(null, 'deployment-secret')).toBe(
|
|
43
|
-
false,
|
|
44
|
-
);
|
|
45
|
-
expect(
|
|
46
|
-
await verifyManagedSessionBffProof(
|
|
47
|
-
proof,
|
|
48
|
-
'different-secret',
|
|
49
|
-
TEST_TIMESTAMP,
|
|
50
|
-
),
|
|
51
|
-
).toBe(false);
|
|
52
|
-
expect(
|
|
53
|
-
await verifyManagedSessionBffProof(
|
|
54
|
-
`${proof?.slice(0, -1)}${proof?.endsWith('0') ? '1' : '0'}`,
|
|
55
|
-
'deployment-secret',
|
|
56
|
-
TEST_TIMESTAMP,
|
|
57
|
-
),
|
|
58
|
-
).toBe(false);
|
|
59
|
-
});
|
|
60
|
-
});
|