@sentio/sdk 1.26.3 → 1.27.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/lib/aptos/aptos-processor.d.ts +1 -1
- package/lib/aptos/aptos-processor.js +2 -2
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/index.d.ts +1 -1
- package/lib/aptos/index.js +2 -1
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos-codegen/codegen.js +37 -15
- package/lib/aptos-codegen/codegen.js.map +1 -1
- package/lib/builtin/aptos/0x1.d.ts +89 -84
- package/lib/builtin/aptos/0x1.js +257 -251
- package/lib/builtin/aptos/0x1.js.map +1 -1
- package/lib/builtin/aptos/0x3.d.ts +8 -8
- package/lib/builtin/aptos/0x3.js +35 -35
- package/lib/builtin/aptos/0x3.js.map +1 -1
- package/lib/cli/cli.js +3 -3
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/commands/login-server.d.ts +7 -0
- package/lib/cli/commands/login-server.js +134 -0
- package/lib/cli/commands/login-server.js.map +1 -0
- package/lib/cli/commands/run-login.js +77 -27
- package/lib/cli/commands/run-login.js.map +1 -1
- package/lib/cli/config.d.ts +5 -0
- package/lib/cli/config.js +28 -1
- package/lib/cli/config.js.map +1 -1
- package/lib/core/exporter.d.ts +4 -9
- package/lib/core/exporter.js +8 -8
- package/lib/core/exporter.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +2 -9
- package/lib/gen/processor/protos/processor.js +15 -54
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/service.js +2 -3
- package/lib/service.js.map +1 -1
- package/lib/tests/erc20.js +1 -5
- package/lib/tests/erc20.js.map +1 -1
- package/lib/tests/types/aptos/souffle.d.ts +2 -2
- package/lib/tests/types/aptos/souffle.js +12 -12
- package/lib/tests/types/aptos/souffle.js.map +1 -1
- package/package.json +7 -2
- package/src/aptos/aptos-processor.ts +2 -2
- package/src/aptos/index.ts +1 -1
- package/src/aptos-codegen/codegen.ts +43 -17
- package/src/builtin/aptos/0x1.ts +301 -283
- package/src/builtin/aptos/0x3.ts +47 -47
- package/src/cli/cli.ts +3 -3
- package/src/cli/commands/login-server.ts +120 -0
- package/src/cli/commands/run-login.ts +59 -28
- package/src/cli/config.ts +29 -0
- package/src/core/exporter.ts +9 -14
- package/src/gen/processor/protos/processor.ts +15 -59
- package/src/service.ts +2 -3
- package/src/tests/erc20.ts +1 -5
- package/src/tests/types/aptos/souffle.ts +12 -12
package/src/builtin/aptos/0x3.ts
CHANGED
|
@@ -139,15 +139,6 @@ export class token extends aptos.AptosBaseProcessor {
|
|
|
139
139
|
return this;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
onEventBurnTokenEvent(
|
|
143
|
-
func: (event: token.BurnTokenEventInstance, ctx: aptos.AptosContext) => void
|
|
144
|
-
): token {
|
|
145
|
-
this.onEvent(func, {
|
|
146
|
-
type: "token::BurnTokenEvent",
|
|
147
|
-
});
|
|
148
|
-
return this;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
142
|
onEventCreateCollectionEvent(
|
|
152
143
|
func: (
|
|
153
144
|
event: token.CreateCollectionEventInstance,
|
|
@@ -172,6 +163,15 @@ export class token extends aptos.AptosBaseProcessor {
|
|
|
172
163
|
return this;
|
|
173
164
|
}
|
|
174
165
|
|
|
166
|
+
onEventMintTokenEvent(
|
|
167
|
+
func: (event: token.MintTokenEventInstance, ctx: aptos.AptosContext) => void
|
|
168
|
+
): token {
|
|
169
|
+
this.onEvent(func, {
|
|
170
|
+
type: "token::MintTokenEvent",
|
|
171
|
+
});
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
175
|
onEventDepositEvent(
|
|
176
176
|
func: (event: token.DepositEventInstance, ctx: aptos.AptosContext) => void
|
|
177
177
|
): token {
|
|
@@ -181,32 +181,32 @@ export class token extends aptos.AptosBaseProcessor {
|
|
|
181
181
|
return this;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
func: (event: token.
|
|
184
|
+
onEventWithdrawEvent(
|
|
185
|
+
func: (event: token.WithdrawEventInstance, ctx: aptos.AptosContext) => void
|
|
186
186
|
): token {
|
|
187
187
|
this.onEvent(func, {
|
|
188
|
-
type: "token::
|
|
188
|
+
type: "token::WithdrawEvent",
|
|
189
189
|
});
|
|
190
190
|
return this;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
|
|
194
|
-
func: (
|
|
195
|
-
event: token.MutateTokenPropertyMapEventInstance,
|
|
196
|
-
ctx: aptos.AptosContext
|
|
197
|
-
) => void
|
|
193
|
+
onEventBurnTokenEvent(
|
|
194
|
+
func: (event: token.BurnTokenEventInstance, ctx: aptos.AptosContext) => void
|
|
198
195
|
): token {
|
|
199
196
|
this.onEvent(func, {
|
|
200
|
-
type: "token::
|
|
197
|
+
type: "token::BurnTokenEvent",
|
|
201
198
|
});
|
|
202
199
|
return this;
|
|
203
200
|
}
|
|
204
201
|
|
|
205
|
-
|
|
206
|
-
func: (
|
|
202
|
+
onEventMutateTokenPropertyMapEvent(
|
|
203
|
+
func: (
|
|
204
|
+
event: token.MutateTokenPropertyMapEventInstance,
|
|
205
|
+
ctx: aptos.AptosContext
|
|
206
|
+
) => void
|
|
207
207
|
): token {
|
|
208
208
|
this.onEvent(func, {
|
|
209
|
-
type: "token::
|
|
209
|
+
type: "token::MutateTokenPropertyMapEvent",
|
|
210
210
|
});
|
|
211
211
|
return this;
|
|
212
212
|
}
|
|
@@ -524,8 +524,8 @@ export namespace token {
|
|
|
524
524
|
type_arguments: [];
|
|
525
525
|
}
|
|
526
526
|
|
|
527
|
-
export function loadTypes(
|
|
528
|
-
loadAllTypes(
|
|
527
|
+
export function loadTypes(_r: aptos.TypeRegistry) {
|
|
528
|
+
loadAllTypes(_r);
|
|
529
529
|
}
|
|
530
530
|
export const ABI: MoveModule = JSON.parse(
|
|
531
531
|
'{"address":"0x3","name":"token","friends":[],"exposed_functions":[{"name":"balance_of","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x3::token::TokenId"],"return":["u64"]},{"name":"burn","visibility":"public","is_entry":true,"generic_type_params":[],"params":["&signer","address","0x1::string::String","0x1::string::String","u64","u64"],"return":[]},{"name":"burn_by_creator","visibility":"public","is_entry":true,"generic_type_params":[],"params":["&signer","address","0x1::string::String","0x1::string::String","u64","u64"],"return":[]},{"name":"check_collection_exists","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x1::string::String"],"return":["bool"]},{"name":"check_tokendata_exists","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x1::string::String","0x1::string::String"],"return":["bool"]},{"name":"create_collection","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String","u64","vector<bool>"],"return":[]},{"name":"create_collection_mutability_config","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&vector<bool>"],"return":["0x3::token::CollectionMutabilityConfig"]},{"name":"create_collection_script","visibility":"public","is_entry":true,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String","u64","vector<bool>"],"return":[]},{"name":"create_token_data_id","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x1::string::String","0x1::string::String"],"return":["0x3::token::TokenDataId"]},{"name":"create_token_id","visibility":"public","is_entry":false,"generic_type_params":[],"params":["0x3::token::TokenDataId","u64"],"return":["0x3::token::TokenId"]},{"name":"create_token_id_raw","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x1::string::String","0x1::string::String","u64"],"return":["0x3::token::TokenId"]},{"name":"create_token_mutability_config","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&vector<bool>"],"return":["0x3::token::TokenMutabilityConfig"]},{"name":"create_token_script","visibility":"public","is_entry":true,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String","u64","u64","0x1::string::String","address","u64","u64","vector<bool>","vector<0x1::string::String>","vector<vector<u8>>","vector<0x1::string::String>"],"return":[]},{"name":"create_tokendata","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x1::string::String","0x1::string::String","0x1::string::String","u64","0x1::string::String","address","u64","u64","0x3::token::TokenMutabilityConfig","vector<0x1::string::String>","vector<vector<u8>>","vector<0x1::string::String>"],"return":["0x3::token::TokenDataId"]},{"name":"create_withdraw_capability","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::TokenId","u64","u64"],"return":["0x3::token::WithdrawCapability"]},{"name":"deposit_token","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::Token"],"return":[]},{"name":"direct_deposit_with_opt_in","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x3::token::Token"],"return":[]},{"name":"direct_transfer","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","&signer","0x3::token::TokenId","u64"],"return":[]},{"name":"direct_transfer_script","visibility":"public","is_entry":true,"generic_type_params":[],"params":["&signer","&signer","address","0x1::string::String","0x1::string::String","u64","u64"],"return":[]},{"name":"get_collection_supply","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x1::string::String"],"return":["0x1::option::Option<u64>"]},{"name":"get_property_map","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x3::token::TokenId"],"return":["0x3::property_map::PropertyMap"]},{"name":"get_royalty","visibility":"public","is_entry":false,"generic_type_params":[],"params":["0x3::token::TokenId"],"return":["0x3::token::Royalty"]},{"name":"get_royalty_denominator","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::token::Royalty"],"return":["u64"]},{"name":"get_royalty_numerator","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::token::Royalty"],"return":["u64"]},{"name":"get_royalty_payee","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::token::Royalty"],"return":["address"]},{"name":"get_token_amount","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::token::Token"],"return":["u64"]},{"name":"get_token_data_id_fields","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::token::TokenDataId"],"return":["address","0x1::string::String","0x1::string::String"]},{"name":"get_token_id","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::token::Token"],"return":["0x3::token::TokenId"]},{"name":"get_token_id_fields","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::token::TokenId"],"return":["address","0x1::string::String","0x1::string::String","u64"]},{"name":"get_token_supply","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x3::token::TokenDataId"],"return":["0x1::option::Option<u64>"]},{"name":"get_tokendata_largest_property_version","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x3::token::TokenDataId"],"return":["u64"]},{"name":"get_tokendata_uri","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address","0x3::token::TokenDataId"],"return":["0x1::string::String"]},{"name":"has_token_store","visibility":"public","is_entry":false,"generic_type_params":[],"params":["address"],"return":["bool"]},{"name":"initialize_token","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::TokenId"],"return":[]},{"name":"initialize_token_script","visibility":"public","is_entry":true,"generic_type_params":[],"params":["&signer"],"return":[]},{"name":"initialize_token_store","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer"],"return":[]},{"name":"merge","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&mut 0x3::token::Token","0x3::token::Token"],"return":[]},{"name":"mint_script","visibility":"public","is_entry":true,"generic_type_params":[],"params":["&signer","address","0x1::string::String","0x1::string::String","u64"],"return":[]},{"name":"mint_token","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::TokenDataId","u64"],"return":["0x3::token::TokenId"]},{"name":"mint_token_to","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","address","0x3::token::TokenDataId","u64"],"return":[]},{"name":"mutate_one_token","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","address","0x3::token::TokenId","vector<0x1::string::String>","vector<vector<u8>>","vector<0x1::string::String>"],"return":["0x3::token::TokenId"]},{"name":"mutate_token_properties","visibility":"public","is_entry":true,"generic_type_params":[],"params":["&signer","address","address","0x1::string::String","0x1::string::String","u64","u64","vector<0x1::string::String>","vector<vector<u8>>","vector<0x1::string::String>"],"return":[]},{"name":"mutate_tokendata_property","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::TokenDataId","vector<0x1::string::String>","vector<vector<u8>>","vector<0x1::string::String>"],"return":[]},{"name":"mutate_tokendata_uri","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::TokenDataId","0x1::string::String"],"return":[]},{"name":"opt_in_direct_transfer","visibility":"public","is_entry":true,"generic_type_params":[],"params":["&signer","bool"],"return":[]},{"name":"split","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&mut 0x3::token::Token","u64"],"return":["0x3::token::Token"]},{"name":"token_id","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::token::Token"],"return":["&0x3::token::TokenId"]},{"name":"transfer","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::TokenId","address","u64"],"return":[]},{"name":"withdraw_token","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::TokenId","u64"],"return":["0x3::token::Token"]},{"name":"withdraw_with_capability","visibility":"public","is_entry":false,"generic_type_params":[],"params":["0x3::token::WithdrawCapability"],"return":["0x3::token::Token"]}],"structs":[{"name":"BurnTokenEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"id","type":"0x3::token::TokenId"},{"name":"amount","type":"u64"}]},{"name":"CollectionData","is_native":false,"abilities":["store"],"generic_type_params":[],"fields":[{"name":"description","type":"0x1::string::String"},{"name":"name","type":"0x1::string::String"},{"name":"uri","type":"0x1::string::String"},{"name":"supply","type":"u64"},{"name":"maximum","type":"u64"},{"name":"mutability_config","type":"0x3::token::CollectionMutabilityConfig"}]},{"name":"CollectionMutabilityConfig","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"description","type":"bool"},{"name":"uri","type":"bool"},{"name":"maximum","type":"bool"}]},{"name":"Collections","is_native":false,"abilities":["key"],"generic_type_params":[],"fields":[{"name":"collection_data","type":"0x1::table::Table<0x1::string::String, 0x3::token::CollectionData>"},{"name":"token_data","type":"0x1::table::Table<0x3::token::TokenDataId, 0x3::token::TokenData>"},{"name":"create_collection_events","type":"0x1::event::EventHandle<0x3::token::CreateCollectionEvent>"},{"name":"create_token_data_events","type":"0x1::event::EventHandle<0x3::token::CreateTokenDataEvent>"},{"name":"mint_token_events","type":"0x1::event::EventHandle<0x3::token::MintTokenEvent>"}]},{"name":"CreateCollectionEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"creator","type":"address"},{"name":"collection_name","type":"0x1::string::String"},{"name":"uri","type":"0x1::string::String"},{"name":"description","type":"0x1::string::String"},{"name":"maximum","type":"u64"}]},{"name":"CreateTokenDataEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"id","type":"0x3::token::TokenDataId"},{"name":"description","type":"0x1::string::String"},{"name":"maximum","type":"u64"},{"name":"uri","type":"0x1::string::String"},{"name":"royalty_payee_address","type":"address"},{"name":"royalty_points_denominator","type":"u64"},{"name":"royalty_points_numerator","type":"u64"},{"name":"name","type":"0x1::string::String"},{"name":"mutability_config","type":"0x3::token::TokenMutabilityConfig"},{"name":"property_keys","type":"vector<0x1::string::String>"},{"name":"property_values","type":"vector<vector<u8>>"},{"name":"property_types","type":"vector<0x1::string::String>"}]},{"name":"DepositEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"id","type":"0x3::token::TokenId"},{"name":"amount","type":"u64"}]},{"name":"MintTokenEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"id","type":"0x3::token::TokenDataId"},{"name":"amount","type":"u64"}]},{"name":"MutateTokenPropertyMapEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"old_id","type":"0x3::token::TokenId"},{"name":"new_id","type":"0x3::token::TokenId"},{"name":"keys","type":"vector<0x1::string::String>"},{"name":"values","type":"vector<vector<u8>>"},{"name":"types","type":"vector<0x1::string::String>"}]},{"name":"Royalty","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"royalty_points_numerator","type":"u64"},{"name":"royalty_points_denominator","type":"u64"},{"name":"payee_address","type":"address"}]},{"name":"Token","is_native":false,"abilities":["store"],"generic_type_params":[],"fields":[{"name":"id","type":"0x3::token::TokenId"},{"name":"amount","type":"u64"},{"name":"token_properties","type":"0x3::property_map::PropertyMap"}]},{"name":"TokenData","is_native":false,"abilities":["store"],"generic_type_params":[],"fields":[{"name":"maximum","type":"u64"},{"name":"largest_property_version","type":"u64"},{"name":"supply","type":"u64"},{"name":"uri","type":"0x1::string::String"},{"name":"royalty","type":"0x3::token::Royalty"},{"name":"name","type":"0x1::string::String"},{"name":"description","type":"0x1::string::String"},{"name":"default_properties","type":"0x3::property_map::PropertyMap"},{"name":"mutability_config","type":"0x3::token::TokenMutabilityConfig"}]},{"name":"TokenDataId","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"creator","type":"address"},{"name":"collection","type":"0x1::string::String"},{"name":"name","type":"0x1::string::String"}]},{"name":"TokenId","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"token_data_id","type":"0x3::token::TokenDataId"},{"name":"property_version","type":"u64"}]},{"name":"TokenMutabilityConfig","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"maximum","type":"bool"},{"name":"uri","type":"bool"},{"name":"royalty","type":"bool"},{"name":"description","type":"bool"},{"name":"properties","type":"bool"}]},{"name":"TokenStore","is_native":false,"abilities":["key"],"generic_type_params":[],"fields":[{"name":"tokens","type":"0x1::table::Table<0x3::token::TokenId, 0x3::token::Token>"},{"name":"direct_transfer","type":"bool"},{"name":"deposit_events","type":"0x1::event::EventHandle<0x3::token::DepositEvent>"},{"name":"withdraw_events","type":"0x1::event::EventHandle<0x3::token::WithdrawEvent>"},{"name":"burn_events","type":"0x1::event::EventHandle<0x3::token::BurnTokenEvent>"},{"name":"mutate_token_property_events","type":"0x1::event::EventHandle<0x3::token::MutateTokenPropertyMapEvent>"}]},{"name":"WithdrawCapability","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"token_owner","type":"address"},{"name":"token_id","type":"0x3::token::TokenId"},{"name":"amount","type":"u64"},{"name":"expiration_sec","type":"u64"}]},{"name":"WithdrawEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"id","type":"0x3::token::TokenId"},{"name":"amount","type":"u64"}]}]}'
|
|
@@ -544,8 +544,8 @@ export namespace property_map {
|
|
|
544
544
|
type: string;
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
-
export function loadTypes(
|
|
548
|
-
loadAllTypes(
|
|
547
|
+
export function loadTypes(_r: aptos.TypeRegistry) {
|
|
548
|
+
loadAllTypes(_r);
|
|
549
549
|
}
|
|
550
550
|
export const ABI: MoveModule = JSON.parse(
|
|
551
551
|
'{"address":"0x3","name":"property_map","friends":[],"exposed_functions":[{"name":"add","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&mut 0x3::property_map::PropertyMap","0x1::string::String","0x3::property_map::PropertyValue"],"return":[]},{"name":"borrow","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyMap","&0x1::string::String"],"return":["&0x3::property_map::PropertyValue"]},{"name":"borrow_type","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyValue"],"return":["0x1::string::String"]},{"name":"borrow_value","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyValue"],"return":["vector<u8>"]},{"name":"contains_key","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyMap","&0x1::string::String"],"return":["bool"]},{"name":"create_property_value","visibility":"public","is_entry":false,"generic_type_params":[{"constraints":["copy"]}],"params":["&T0"],"return":["0x3::property_map::PropertyValue"]},{"name":"create_property_value_raw","visibility":"public","is_entry":false,"generic_type_params":[],"params":["vector<u8>","0x1::string::String"],"return":["0x3::property_map::PropertyValue"]},{"name":"empty","visibility":"public","is_entry":false,"generic_type_params":[],"params":[],"return":["0x3::property_map::PropertyMap"]},{"name":"length","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyMap"],"return":["u64"]},{"name":"new","visibility":"public","is_entry":false,"generic_type_params":[],"params":["vector<0x1::string::String>","vector<vector<u8>>","vector<0x1::string::String>"],"return":["0x3::property_map::PropertyMap"]},{"name":"read_address","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyMap","&0x1::string::String"],"return":["address"]},{"name":"read_bool","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyMap","&0x1::string::String"],"return":["bool"]},{"name":"read_string","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyMap","&0x1::string::String"],"return":["0x1::string::String"]},{"name":"read_u128","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyMap","&0x1::string::String"],"return":["u128"]},{"name":"read_u64","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyMap","&0x1::string::String"],"return":["u64"]},{"name":"read_u8","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&0x3::property_map::PropertyMap","&0x1::string::String"],"return":["u8"]},{"name":"remove","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&mut 0x3::property_map::PropertyMap","&0x1::string::String"],"return":["0x1::string::String","0x3::property_map::PropertyValue"]},{"name":"update_property_map","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&mut 0x3::property_map::PropertyMap","vector<0x1::string::String>","vector<vector<u8>>","vector<0x1::string::String>"],"return":[]},{"name":"update_property_value","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&mut 0x3::property_map::PropertyMap","&0x1::string::String","0x3::property_map::PropertyValue"],"return":[]}],"structs":[{"name":"PropertyMap","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"map","type":"0x1::simple_map::SimpleMap<0x1::string::String, 0x3::property_map::PropertyValue>"}]},{"name":"PropertyValue","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"value","type":"vector<u8>"},{"name":"type","type":"0x1::string::String"}]}]}'
|
|
@@ -674,8 +674,8 @@ export namespace token_coin_swap {
|
|
|
674
674
|
type_arguments: [string];
|
|
675
675
|
}
|
|
676
676
|
|
|
677
|
-
export function loadTypes(
|
|
678
|
-
loadAllTypes(
|
|
677
|
+
export function loadTypes(_r: aptos.TypeRegistry) {
|
|
678
|
+
loadAllTypes(_r);
|
|
679
679
|
}
|
|
680
680
|
export const ABI: MoveModule = JSON.parse(
|
|
681
681
|
'{"address":"0x3","name":"token_coin_swap","friends":[],"exposed_functions":[{"name":"cancel_token_listing","visibility":"public","is_entry":false,"generic_type_params":[{"constraints":[]}],"params":["&signer","0x3::token::TokenId","u64"],"return":[]},{"name":"deposit_token_to_escrow","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::TokenId","0x3::token::Token","u64"],"return":[]},{"name":"does_listing_exist","visibility":"public","is_entry":false,"generic_type_params":[{"constraints":[]}],"params":["address","0x3::token::TokenId"],"return":["bool"]},{"name":"exchange_coin_for_token","visibility":"public","is_entry":false,"generic_type_params":[{"constraints":[]}],"params":["&signer","u64","address","address","0x1::string::String","0x1::string::String","u64","u64"],"return":[]},{"name":"list_token_for_swap","visibility":"public","is_entry":true,"generic_type_params":[{"constraints":[]}],"params":["&signer","address","0x1::string::String","0x1::string::String","u64","u64","u64","u64"],"return":[]},{"name":"withdraw_token_from_escrow","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","0x3::token::TokenId","u64"],"return":["0x3::token::Token"]}],"structs":[{"name":"TokenCoinSwap","is_native":false,"abilities":["drop","store"],"generic_type_params":[{"constraints":[]}],"fields":[{"name":"token_amount","type":"u64"},{"name":"min_price_per_token","type":"u64"}]},{"name":"TokenEscrow","is_native":false,"abilities":["store"],"generic_type_params":[],"fields":[{"name":"token","type":"0x3::token::Token"},{"name":"locked_until_secs","type":"u64"}]},{"name":"TokenListingEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"token_id","type":"0x3::token::TokenId"},{"name":"amount","type":"u64"},{"name":"min_price","type":"u64"},{"name":"locked_until_secs","type":"u64"},{"name":"coin_type_info","type":"0x1::type_info::TypeInfo"}]},{"name":"TokenListings","is_native":false,"abilities":["key"],"generic_type_params":[{"constraints":[]}],"fields":[{"name":"listings","type":"0x1::table::Table<0x3::token::TokenId, 0x3::token_coin_swap::TokenCoinSwap<T0>>"},{"name":"listing_events","type":"0x1::event::EventHandle<0x3::token_coin_swap::TokenListingEvent>"},{"name":"swap_events","type":"0x1::event::EventHandle<0x3::token_coin_swap::TokenSwapEvent>"}]},{"name":"TokenStoreEscrow","is_native":false,"abilities":["key"],"generic_type_params":[],"fields":[{"name":"token_escrows","type":"0x1::table::Table<0x3::token::TokenId, 0x3::token_coin_swap::TokenEscrow>"}]},{"name":"TokenSwapEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"token_id","type":"0x3::token::TokenId"},{"name":"token_buyer","type":"address"},{"name":"token_amount","type":"u64"},{"name":"coin_amount","type":"u64"},{"name":"coin_type_info","type":"0x1::type_info::TypeInfo"}]}]}'
|
|
@@ -740,38 +740,38 @@ export class token_transfers extends aptos.AptosBaseProcessor {
|
|
|
740
740
|
return this;
|
|
741
741
|
}
|
|
742
742
|
|
|
743
|
-
|
|
743
|
+
onEventTokenOfferEvent(
|
|
744
744
|
func: (
|
|
745
|
-
event: token_transfers.
|
|
745
|
+
event: token_transfers.TokenOfferEventInstance,
|
|
746
746
|
ctx: aptos.AptosContext
|
|
747
747
|
) => void
|
|
748
748
|
): token_transfers {
|
|
749
749
|
this.onEvent(func, {
|
|
750
|
-
type: "token_transfers::
|
|
750
|
+
type: "token_transfers::TokenOfferEvent",
|
|
751
751
|
});
|
|
752
752
|
return this;
|
|
753
753
|
}
|
|
754
754
|
|
|
755
|
-
|
|
755
|
+
onEventTokenCancelOfferEvent(
|
|
756
756
|
func: (
|
|
757
|
-
event: token_transfers.
|
|
757
|
+
event: token_transfers.TokenCancelOfferEventInstance,
|
|
758
758
|
ctx: aptos.AptosContext
|
|
759
759
|
) => void
|
|
760
760
|
): token_transfers {
|
|
761
761
|
this.onEvent(func, {
|
|
762
|
-
type: "token_transfers::
|
|
762
|
+
type: "token_transfers::TokenCancelOfferEvent",
|
|
763
763
|
});
|
|
764
764
|
return this;
|
|
765
765
|
}
|
|
766
766
|
|
|
767
|
-
|
|
767
|
+
onEventTokenClaimEvent(
|
|
768
768
|
func: (
|
|
769
|
-
event: token_transfers.
|
|
769
|
+
event: token_transfers.TokenClaimEventInstance,
|
|
770
770
|
ctx: aptos.AptosContext
|
|
771
771
|
) => void
|
|
772
772
|
): token_transfers {
|
|
773
773
|
this.onEvent(func, {
|
|
774
|
-
type: "token_transfers::
|
|
774
|
+
type: "token_transfers::TokenClaimEvent",
|
|
775
775
|
});
|
|
776
776
|
return this;
|
|
777
777
|
}
|
|
@@ -859,22 +859,22 @@ export namespace token_transfers {
|
|
|
859
859
|
type_arguments: [];
|
|
860
860
|
}
|
|
861
861
|
|
|
862
|
-
export function loadTypes(
|
|
863
|
-
loadAllTypes(
|
|
862
|
+
export function loadTypes(_r: aptos.TypeRegistry) {
|
|
863
|
+
loadAllTypes(_r);
|
|
864
864
|
}
|
|
865
865
|
export const ABI: MoveModule = JSON.parse(
|
|
866
866
|
'{"address":"0x3","name":"token_transfers","friends":[],"exposed_functions":[{"name":"cancel_offer","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","address","0x3::token::TokenId"],"return":[]},{"name":"cancel_offer_script","visibility":"public","is_entry":true,"generic_type_params":[],"params":["signer","address","address","0x1::string::String","0x1::string::String","u64"],"return":[]},{"name":"claim","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","address","0x3::token::TokenId"],"return":[]},{"name":"claim_script","visibility":"public","is_entry":true,"generic_type_params":[],"params":["signer","address","address","0x1::string::String","0x1::string::String","u64"],"return":[]},{"name":"offer","visibility":"public","is_entry":false,"generic_type_params":[],"params":["&signer","address","0x3::token::TokenId","u64"],"return":[]},{"name":"offer_script","visibility":"public","is_entry":true,"generic_type_params":[],"params":["signer","address","address","0x1::string::String","0x1::string::String","u64","u64"],"return":[]}],"structs":[{"name":"PendingClaims","is_native":false,"abilities":["key"],"generic_type_params":[],"fields":[{"name":"pending_claims","type":"0x1::table::Table<0x3::token_transfers::TokenOfferId, 0x3::token::Token>"},{"name":"offer_events","type":"0x1::event::EventHandle<0x3::token_transfers::TokenOfferEvent>"},{"name":"cancel_offer_events","type":"0x1::event::EventHandle<0x3::token_transfers::TokenCancelOfferEvent>"},{"name":"claim_events","type":"0x1::event::EventHandle<0x3::token_transfers::TokenClaimEvent>"}]},{"name":"TokenCancelOfferEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"to_address","type":"address"},{"name":"token_id","type":"0x3::token::TokenId"},{"name":"amount","type":"u64"}]},{"name":"TokenClaimEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"to_address","type":"address"},{"name":"token_id","type":"0x3::token::TokenId"},{"name":"amount","type":"u64"}]},{"name":"TokenOfferEvent","is_native":false,"abilities":["drop","store"],"generic_type_params":[],"fields":[{"name":"to_address","type":"address"},{"name":"token_id","type":"0x3::token::TokenId"},{"name":"amount","type":"u64"}]},{"name":"TokenOfferId","is_native":false,"abilities":["copy","drop","store"],"generic_type_params":[],"fields":[{"name":"to_addr","type":"address"},{"name":"token_id","type":"0x3::token::TokenId"}]}]}'
|
|
867
867
|
);
|
|
868
868
|
}
|
|
869
869
|
|
|
870
|
-
function loadAllTypes(
|
|
871
|
-
table.loadTypes(
|
|
872
|
-
event.loadTypes(
|
|
873
|
-
simple_map.loadTypes(
|
|
874
|
-
type_info.loadTypes(
|
|
870
|
+
function loadAllTypes(_r: aptos.TypeRegistry) {
|
|
871
|
+
table.loadTypes(_r);
|
|
872
|
+
event.loadTypes(_r);
|
|
873
|
+
simple_map.loadTypes(_r);
|
|
874
|
+
type_info.loadTypes(_r);
|
|
875
875
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
876
|
+
_r.load(token.ABI);
|
|
877
|
+
_r.load(property_map.ABI);
|
|
878
|
+
_r.load(token_coin_swap.ABI);
|
|
879
|
+
_r.load(token_transfers.ABI);
|
|
880
880
|
}
|
package/src/cli/cli.ts
CHANGED
|
@@ -10,9 +10,9 @@ import { finalizeHost, FinalizeProjectName, SentioProjectConfig } from './config
|
|
|
10
10
|
import { uploadFile } from './upload'
|
|
11
11
|
import chalk from 'chalk'
|
|
12
12
|
import { buildProcessor } from './build'
|
|
13
|
-
import { runLogin } from './commands/run-login'
|
|
14
13
|
import { runCreate } from './commands/run-create'
|
|
15
14
|
import { runVersion } from './commands/run-version'
|
|
15
|
+
import { runLogin } from './commands/run-login'
|
|
16
16
|
|
|
17
17
|
const mainDefinitions = [{ name: 'command', defaultOption: true }]
|
|
18
18
|
const mainOptions = commandLineArgs(mainDefinitions, {
|
|
@@ -159,12 +159,12 @@ function usage() {
|
|
|
159
159
|
header: 'Usage',
|
|
160
160
|
content: [
|
|
161
161
|
'sentio <command> --help\t\tshow detail usage of specific command',
|
|
162
|
-
'sentio login
|
|
162
|
+
'sentio login\t\t\t\tlogin to sentio',
|
|
163
163
|
'sentio create\t\t\t\tcreate a template project',
|
|
164
164
|
'sentio upload\t\t\t\tbuild and upload processor to sentio',
|
|
165
165
|
'sentio gen\t\t\t\tgenerate abi',
|
|
166
166
|
'sentio build\t\t\t\tgenerate abi and build',
|
|
167
|
-
'sentio version\t\t\
|
|
167
|
+
'sentio version\t\t\tcurrent cli version',
|
|
168
168
|
],
|
|
169
169
|
},
|
|
170
170
|
])
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import express from 'express'
|
|
2
|
+
import { getAuthConfig, getFinalizedHost } from '../config'
|
|
3
|
+
import url, { URL } from 'url'
|
|
4
|
+
import fetch from 'node-fetch'
|
|
5
|
+
import { getCliVersion } from '../utils'
|
|
6
|
+
import { WriteKey } from '../key'
|
|
7
|
+
import chalk from 'chalk'
|
|
8
|
+
import http from 'http'
|
|
9
|
+
import os from 'os'
|
|
10
|
+
import * as crypto from 'crypto'
|
|
11
|
+
|
|
12
|
+
interface AuthParams {
|
|
13
|
+
serverPort: number
|
|
14
|
+
sentioHost: string
|
|
15
|
+
codeVerifier: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const app = express()
|
|
19
|
+
|
|
20
|
+
let server: http.Server
|
|
21
|
+
let authParams: AuthParams
|
|
22
|
+
|
|
23
|
+
export function startServer(params: AuthParams) {
|
|
24
|
+
authParams = params
|
|
25
|
+
server = app.listen(params.serverPort)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
app.get('/callback', async (req, res) => {
|
|
29
|
+
res.end('login success, please go back to CLI to continue')
|
|
30
|
+
const host = authParams.sentioHost
|
|
31
|
+
const code = req.query.code
|
|
32
|
+
if (!code || (code as string).length == 0) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// exchange token
|
|
37
|
+
const tokenResRaw = await getToken(host, code as string)
|
|
38
|
+
if (!tokenResRaw.ok) {
|
|
39
|
+
console.error(chalk.red('request token error, code:', tokenResRaw.status, tokenResRaw.statusText))
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
const tokenRes = await tokenResRaw.json()
|
|
43
|
+
const accessToken = tokenRes['access_token']
|
|
44
|
+
|
|
45
|
+
// check if the account is ready
|
|
46
|
+
const realHost = getFinalizedHost(host)
|
|
47
|
+
const userResRaw = await getUser(realHost, accessToken)
|
|
48
|
+
if (!userResRaw.ok) {
|
|
49
|
+
if (userResRaw.status == 401) {
|
|
50
|
+
console.error(chalk.red('please sign up on sentio first'))
|
|
51
|
+
} else {
|
|
52
|
+
console.error(chalk.red('get user error, code:', userResRaw.status, userResRaw.statusText))
|
|
53
|
+
}
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
const userRes = await userResRaw.json()
|
|
57
|
+
if (!userRes.emailVerified) {
|
|
58
|
+
console.error(chalk.red('please verify your email first'))
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// create API key
|
|
63
|
+
const apiKeyName = `${os.hostname()}-${crypto.randomBytes(4).toString('hex')}`
|
|
64
|
+
const createApiKeyResRaw = await createApiKey(realHost, apiKeyName, 'sdk_generated', accessToken)
|
|
65
|
+
if (!createApiKeyResRaw.ok) {
|
|
66
|
+
console.error(chalk.red('create api key error, code:', createApiKeyResRaw.status, createApiKeyResRaw.statusText))
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
const createApiKeyRes = await createApiKeyResRaw.json()
|
|
70
|
+
const apiKey = createApiKeyRes['key']
|
|
71
|
+
WriteKey(realHost, apiKey)
|
|
72
|
+
console.log(chalk.green('login success, new API key: ' + apiKey))
|
|
73
|
+
|
|
74
|
+
server.close()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
async function getToken(host: string, code: string) {
|
|
78
|
+
const authConf = getAuthConfig(host)
|
|
79
|
+
const params = new url.URLSearchParams({
|
|
80
|
+
grant_type: 'authorization_code',
|
|
81
|
+
client_id: authConf.clientId,
|
|
82
|
+
code_verifier: authParams.codeVerifier,
|
|
83
|
+
code: code,
|
|
84
|
+
redirect_uri: `http://localhost:${authParams.serverPort}/callback`,
|
|
85
|
+
})
|
|
86
|
+
return fetch(`${authConf.domain}/oauth/token`, {
|
|
87
|
+
method: 'POST',
|
|
88
|
+
headers: {
|
|
89
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
90
|
+
},
|
|
91
|
+
body: params.toString(),
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function createApiKey(host: string, name: string, source: string, accessToken: string) {
|
|
96
|
+
const createApiKeyUrl = new URL('/api/v1/keys', host)
|
|
97
|
+
return fetch(createApiKeyUrl, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: {
|
|
100
|
+
Authorization: 'Bearer ' + accessToken,
|
|
101
|
+
version: getCliVersion(),
|
|
102
|
+
},
|
|
103
|
+
body: JSON.stringify({
|
|
104
|
+
name: name,
|
|
105
|
+
scopes: ['write:project'],
|
|
106
|
+
source: source,
|
|
107
|
+
}),
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function getUser(host: string, accessToken: string) {
|
|
112
|
+
const getUserUrl = new URL('/api/v1/users', host)
|
|
113
|
+
return fetch(getUserUrl, {
|
|
114
|
+
method: 'GET',
|
|
115
|
+
headers: {
|
|
116
|
+
Authorization: 'Bearer ' + accessToken,
|
|
117
|
+
version: getCliVersion(),
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import commandLineArgs from 'command-line-args'
|
|
2
2
|
import commandLineUsage from 'command-line-usage'
|
|
3
|
-
import { getFinalizedHost } from '../config'
|
|
3
|
+
import { getAuthConfig, getFinalizedHost } from '../config'
|
|
4
|
+
import { startServer } from './login-server'
|
|
5
|
+
import url, { URL } from 'url'
|
|
6
|
+
import * as crypto from 'crypto'
|
|
4
7
|
import chalk from 'chalk'
|
|
5
|
-
import https from 'https'
|
|
6
|
-
import http from 'http'
|
|
7
8
|
import { WriteKey } from '../key'
|
|
9
|
+
import fetch from 'node-fetch'
|
|
10
|
+
|
|
11
|
+
const port = 20000
|
|
8
12
|
|
|
9
13
|
export function runLogin(argv: string[]) {
|
|
10
14
|
const optionDefinitions = [
|
|
@@ -15,23 +19,23 @@ export function runLogin(argv: string[]) {
|
|
|
15
19
|
description: 'Display this usage guide.',
|
|
16
20
|
},
|
|
17
21
|
{
|
|
18
|
-
name: '
|
|
22
|
+
name: 'host',
|
|
23
|
+
description: '(Optional) Override Sentio Host name',
|
|
19
24
|
type: String,
|
|
20
|
-
description: '(Required) Your API key',
|
|
21
25
|
},
|
|
22
26
|
{
|
|
23
|
-
name: '
|
|
24
|
-
description: '(Optional) Override Sentio Host name',
|
|
27
|
+
name: 'api-key',
|
|
25
28
|
type: String,
|
|
29
|
+
description: '(Optional) Your API key',
|
|
26
30
|
},
|
|
27
31
|
]
|
|
28
32
|
const options = commandLineArgs(optionDefinitions, { argv })
|
|
29
33
|
|
|
30
|
-
if (options.help
|
|
34
|
+
if (options.help) {
|
|
31
35
|
const usage = commandLineUsage([
|
|
32
36
|
{
|
|
33
37
|
header: 'Login to Sentio',
|
|
34
|
-
content: 'sentio login
|
|
38
|
+
content: 'sentio login',
|
|
35
39
|
},
|
|
36
40
|
{
|
|
37
41
|
header: 'Options',
|
|
@@ -39,32 +43,59 @@ export function runLogin(argv: string[]) {
|
|
|
39
43
|
},
|
|
40
44
|
])
|
|
41
45
|
console.log(usage)
|
|
42
|
-
} else {
|
|
46
|
+
} else if (options['api-key']) {
|
|
43
47
|
const host = getFinalizedHost(options.host)
|
|
44
48
|
console.log(chalk.blue('login to ' + host))
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
path: '/api/v1/processors/check_key',
|
|
50
|
-
method: 'HEAD',
|
|
51
|
-
headers: {
|
|
52
|
-
'api-key': options['api-key'],
|
|
53
|
-
},
|
|
54
|
-
}
|
|
55
|
-
const h = url.protocol == 'https:' ? https : http
|
|
56
|
-
const req = h.request(reqOptions, (res) => {
|
|
57
|
-
if (res.statusCode == 200) {
|
|
58
|
-
WriteKey(host, options['api-key'])
|
|
49
|
+
const apiKey = options['api-key']
|
|
50
|
+
checkKey(host, apiKey).then((res) => {
|
|
51
|
+
if (res.status == 200) {
|
|
52
|
+
WriteKey(host, apiKey)
|
|
59
53
|
console.log(chalk.green('login success'))
|
|
60
54
|
} else {
|
|
61
|
-
console.error(chalk.red('login failed, code:', res.
|
|
55
|
+
console.error(chalk.red('login failed, code:', res.status, res.statusText))
|
|
62
56
|
}
|
|
63
57
|
})
|
|
58
|
+
} else {
|
|
59
|
+
// https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-authorization-code-flow-with-pkce
|
|
60
|
+
const verifier = base64URLEncode(crypto.randomBytes(32))
|
|
61
|
+
const challenge = base64URLEncode(sha256(verifier))
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
const conf = getAuthConfig(options.host)
|
|
64
|
+
const authURL = new URL(conf.domain + `/authorize?`)
|
|
65
|
+
const params = new url.URLSearchParams({
|
|
66
|
+
response_type: 'code',
|
|
67
|
+
code_challenge: challenge,
|
|
68
|
+
code_challenge_method: 'S256',
|
|
69
|
+
client_id: conf.clientId,
|
|
70
|
+
redirect_uri: `http://localhost:${port}/callback`,
|
|
71
|
+
audience: conf.audience,
|
|
72
|
+
prompt: 'login',
|
|
73
|
+
})
|
|
74
|
+
authURL.search = params.toString()
|
|
75
|
+
console.log('Continue your authorization here: ' + authURL.toString())
|
|
76
|
+
|
|
77
|
+
startServer({
|
|
78
|
+
serverPort: port,
|
|
79
|
+
sentioHost: options.host,
|
|
80
|
+
codeVerifier: verifier,
|
|
67
81
|
})
|
|
68
|
-
req.end()
|
|
69
82
|
}
|
|
70
83
|
}
|
|
84
|
+
|
|
85
|
+
function base64URLEncode(str: Buffer) {
|
|
86
|
+
return str.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function sha256(str: string) {
|
|
90
|
+
return crypto.createHash('sha256').update(str).digest()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function checkKey(host: string, apiKey: string) {
|
|
94
|
+
const checkApiKeyUrl = new URL('/api/v1/processors/check_key', host)
|
|
95
|
+
return fetch(checkApiKeyUrl, {
|
|
96
|
+
method: 'HEAD',
|
|
97
|
+
headers: {
|
|
98
|
+
'api-key': apiKey,
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
}
|
package/src/cli/config.ts
CHANGED
|
@@ -22,6 +22,35 @@ export function getFinalizedHost(host: string): string {
|
|
|
22
22
|
return host
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
export function getAuthConfig(host: string): { domain: string; clientId: string; audience: string } {
|
|
26
|
+
let domain = '',
|
|
27
|
+
clientId = '',
|
|
28
|
+
audience = ''
|
|
29
|
+
switch (host) {
|
|
30
|
+
case 'local':
|
|
31
|
+
domain = 'https://sentio-dev.us.auth0.com'
|
|
32
|
+
clientId = 'qGDisObqQbcPeRA8k02POPZ2Df4KVCna'
|
|
33
|
+
audience = 'http://localhost:8080/v1'
|
|
34
|
+
break
|
|
35
|
+
case '':
|
|
36
|
+
case undefined:
|
|
37
|
+
case 'prod':
|
|
38
|
+
domain = 'https://auth.sentio.xyz'
|
|
39
|
+
clientId = 'xd80PeuvuZVHpBFh7yEdlSZdtE5mTpGe'
|
|
40
|
+
audience = 'https://app.sentio.xyz/api/v1'
|
|
41
|
+
break
|
|
42
|
+
case 'test':
|
|
43
|
+
case 'staging':
|
|
44
|
+
domain = 'https://auth.test.sentio.xyz'
|
|
45
|
+
clientId = 'qXVvovHaOE37SndxTZJxCKgZjw1axPax'
|
|
46
|
+
audience = 'https://test.sentio.xyz/api/v1'
|
|
47
|
+
break
|
|
48
|
+
default:
|
|
49
|
+
break
|
|
50
|
+
}
|
|
51
|
+
return { domain, clientId, audience }
|
|
52
|
+
}
|
|
53
|
+
|
|
25
54
|
export function finalizeHost(config: SentioProjectConfig) {
|
|
26
55
|
config.host = getFinalizedHost(config.host)
|
|
27
56
|
}
|
package/src/core/exporter.ts
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import { BaseContext } from './context'
|
|
2
|
-
import { DataDescriptor, ExportResult
|
|
2
|
+
import { DataDescriptor, ExportResult } from '@sentio/sdk'
|
|
3
3
|
|
|
4
4
|
export type Export = Record<string, any>
|
|
5
5
|
|
|
6
|
-
export interface ExporterOptions {
|
|
7
|
-
exportType: ExportConfig_ExportType
|
|
8
|
-
exportUrl: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
6
|
export class Exporter {
|
|
12
|
-
static register(
|
|
13
|
-
const exporter = new Exporter(
|
|
7
|
+
static register(name: string, channel: string) {
|
|
8
|
+
const exporter = new Exporter(name, channel)
|
|
14
9
|
global.PROCESSOR_STATE.exporters.push(exporter)
|
|
15
10
|
return exporter
|
|
16
11
|
}
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
protected constructor(
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
13
|
+
name: string
|
|
14
|
+
channel: string
|
|
15
|
+
protected constructor(name: string, channel: string) {
|
|
16
|
+
this.name = name
|
|
17
|
+
this.channel = channel
|
|
23
18
|
}
|
|
24
19
|
|
|
25
20
|
emit(ctx: BaseContext, data: Export) {
|
|
26
21
|
const res: ExportResult = {
|
|
27
|
-
metadata: ctx.getMetaData(DataDescriptor.fromPartial({ name: this.
|
|
22
|
+
metadata: ctx.getMetaData(DataDescriptor.fromPartial({ name: this.name }), {}),
|
|
28
23
|
payload: JSON.stringify(data),
|
|
29
24
|
runtimeInfo: undefined,
|
|
30
25
|
}
|