1
+ import json
2
+ import os
3
+
4
+ import http .client
5
+
6
+ def register_core_version (supertokens_api_key , core_version , plugin_interface_array , core_driver_array ):
7
+ print ("Core Version: " , core_version )
8
+ print ("Plugin Interface Array: " , plugin_interface_array )
9
+ print ("Core Driver Array: " , core_driver_array )
10
+
11
+ conn = http .client .HTTPSConnection ("api.supertokens.io" )
12
+
13
+ payload = {
14
+ "password" : supertokens_api_key ,
15
+ "planType" : "FREE" ,
16
+ "version" : core_version ,
17
+ "pluginInterfaces" : plugin_interface_array ,
18
+ "coreDriverInterfaces" : core_driver_array
19
+ }
20
+
21
+ headers = {
22
+ 'Content-Type' : 'application/json' ,
23
+ 'api-version' : '0'
24
+ }
25
+
26
+ conn .request ("PUT" , "/0/core" , json .dumps (payload ), headers )
27
+ response = conn .getresponse ()
28
+
29
+ if response .status != 200 :
30
+ print (f"failed core PUT API status code: { response .status } . Exiting!" )
31
+ exit (1 )
32
+
33
+ conn .close ()
34
+
35
+
36
+ def read_core_version ():
37
+ with open ('build.gradle' , 'r' ) as file :
38
+ for line in file :
39
+ if 'version =' in line :
40
+ return line .split ('=' )[1 ].strip ().strip ("'\" " )
41
+ raise Exception ("Could not find version in build.gradle" )
42
+
43
+ core_version = read_core_version ()
44
+
45
+ with open ('pluginInterfaceSupported.json' , 'r' ) as fd :
46
+ plugin_interface_array = json .load (fd )['versions' ]
47
+
48
+ with open ('coreDriverInterfaceSupported.json' , 'r' ) as fd :
49
+ core_driver_array = json .load (fd )['versions' ]
50
+
51
+ register_core_version (
52
+ supertokens_api_key = os .environ .get ("SUPERTOKENS_API_KEY" ),
53
+ core_version = core_version ,
54
+ plugin_interface_array = plugin_interface_array ,
55
+ core_driver_array = core_driver_array
56
+ )
0 commit comments