@based/client 2.7.5 → 2.10.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.
Files changed (117) hide show
  1. package/dist/Client.d.ts +3 -0
  2. package/dist/Client.js +16 -1
  3. package/dist/Client.js.map +1 -1
  4. package/dist/Emitter.d.ts +0 -0
  5. package/dist/Emitter.js +0 -0
  6. package/dist/Emitter.js.map +0 -0
  7. package/dist/auth.d.ts +4 -1
  8. package/dist/auth.js +11 -1
  9. package/dist/auth.js.map +1 -1
  10. package/dist/createError.d.ts +0 -0
  11. package/dist/createError.js +0 -0
  12. package/dist/createError.js.map +0 -0
  13. package/dist/debug.d.ts +2 -0
  14. package/dist/debug.js +21 -0
  15. package/dist/debug.js.map +1 -0
  16. package/dist/file/fetch.d.ts +0 -0
  17. package/dist/file/fetch.js +0 -0
  18. package/dist/file/fetch.js.map +0 -0
  19. package/dist/file/getUrl.d.ts +0 -0
  20. package/dist/file/getUrl.js +0 -0
  21. package/dist/file/getUrl.js.map +0 -0
  22. package/dist/file/index.d.ts +0 -0
  23. package/dist/file/index.js +0 -0
  24. package/dist/file/index.js.map +0 -0
  25. package/dist/file/stream/browser.d.ts +0 -0
  26. package/dist/file/stream/browser.js +0 -0
  27. package/dist/file/stream/browser.js.map +0 -0
  28. package/dist/file/stream/index.d.ts +0 -0
  29. package/dist/file/stream/index.js +0 -0
  30. package/dist/file/stream/index.js.map +0 -0
  31. package/dist/file/uploadFileBrowser.d.ts +0 -0
  32. package/dist/file/uploadFileBrowser.js +0 -0
  33. package/dist/file/uploadFileBrowser.js.map +0 -0
  34. package/dist/findPrefix.d.ts +0 -0
  35. package/dist/findPrefix.js +0 -0
  36. package/dist/findPrefix.js.map +0 -0
  37. package/dist/idleTimeout.d.ts +0 -0
  38. package/dist/idleTimeout.js +0 -0
  39. package/dist/idleTimeout.js.map +0 -0
  40. package/dist/index.d.ts +2 -1
  41. package/dist/index.js +5 -5
  42. package/dist/index.js.map +1 -1
  43. package/dist/observable/index.d.ts +0 -0
  44. package/dist/observable/index.js +0 -0
  45. package/dist/observable/index.js.map +0 -0
  46. package/dist/printBasedObject.d.ts +0 -0
  47. package/dist/printBasedObject.js +1 -0
  48. package/dist/printBasedObject.js.map +1 -1
  49. package/dist/queue.d.ts +0 -0
  50. package/dist/queue.js +3 -0
  51. package/dist/queue.js.map +1 -1
  52. package/dist/request.d.ts +0 -0
  53. package/dist/request.js +0 -0
  54. package/dist/request.js.map +0 -0
  55. package/dist/selvaTypes/get.d.ts +0 -0
  56. package/dist/selvaTypes/get.js +0 -0
  57. package/dist/selvaTypes/get.js.map +0 -0
  58. package/dist/selvaTypes/schema.d.ts +0 -0
  59. package/dist/selvaTypes/schema.js +0 -0
  60. package/dist/selvaTypes/schema.js.map +0 -0
  61. package/dist/selvaTypes/set.d.ts +0 -0
  62. package/dist/selvaTypes/set.js +0 -0
  63. package/dist/selvaTypes/set.js.map +0 -0
  64. package/dist/subscriptions/addGetSubscriber.d.ts +0 -0
  65. package/dist/subscriptions/addGetSubscriber.js +0 -0
  66. package/dist/subscriptions/addGetSubscriber.js.map +0 -0
  67. package/dist/subscriptions/addSubscriber.d.ts +0 -0
  68. package/dist/subscriptions/addSubscriber.js +0 -0
  69. package/dist/subscriptions/addSubscriber.js.map +0 -0
  70. package/dist/subscriptions/generateId.d.ts +0 -0
  71. package/dist/subscriptions/generateId.js +0 -0
  72. package/dist/subscriptions/generateId.js.map +0 -0
  73. package/dist/subscriptions/incomingSubscription.d.ts +0 -0
  74. package/dist/subscriptions/incomingSubscription.js +0 -0
  75. package/dist/subscriptions/incomingSubscription.js.map +0 -0
  76. package/dist/subscriptions/incomingSubscriptionDiff.d.ts +0 -0
  77. package/dist/subscriptions/incomingSubscriptionDiff.js +0 -0
  78. package/dist/subscriptions/incomingSubscriptionDiff.js.map +0 -0
  79. package/dist/subscriptions/index.d.ts +0 -0
  80. package/dist/subscriptions/index.js +0 -0
  81. package/dist/subscriptions/index.js.map +0 -0
  82. package/dist/subscriptions/logoutSubscriptions.d.ts +0 -0
  83. package/dist/subscriptions/logoutSubscriptions.js +0 -0
  84. package/dist/subscriptions/logoutSubscriptions.js.map +0 -0
  85. package/dist/subscriptions/removeSendSubscriptionDataFromQueue.d.ts +0 -0
  86. package/dist/subscriptions/removeSendSubscriptionDataFromQueue.js +0 -0
  87. package/dist/subscriptions/removeSendSubscriptionDataFromQueue.js.map +0 -0
  88. package/dist/subscriptions/removeSubscriber.d.ts +0 -0
  89. package/dist/subscriptions/removeSubscriber.js +0 -0
  90. package/dist/subscriptions/removeSubscriber.js.map +0 -0
  91. package/dist/subscriptions/removeUnsubscribesFromQueue.d.ts +0 -0
  92. package/dist/subscriptions/removeUnsubscribesFromQueue.js +0 -0
  93. package/dist/subscriptions/removeUnsubscribesFromQueue.js.map +0 -0
  94. package/dist/subscriptions/sendAllSubscriptions.d.ts +0 -0
  95. package/dist/subscriptions/sendAllSubscriptions.js +0 -0
  96. package/dist/subscriptions/sendAllSubscriptions.js.map +0 -0
  97. package/dist/token.d.ts +0 -0
  98. package/dist/token.js +0 -0
  99. package/dist/token.js.map +0 -0
  100. package/dist/track.d.ts +0 -0
  101. package/dist/track.js +0 -0
  102. package/dist/track.js.map +0 -0
  103. package/dist/websocket/index.d.ts +0 -0
  104. package/dist/websocket/index.js +0 -0
  105. package/dist/websocket/index.js.map +0 -0
  106. package/dist/websocket/types.d.ts +0 -0
  107. package/dist/websocket/types.js +0 -0
  108. package/dist/websocket/types.js.map +0 -0
  109. package/dist/websocket/urlLoader.d.ts +0 -0
  110. package/dist/websocket/urlLoader.js +0 -0
  111. package/dist/websocket/urlLoader.js.map +0 -0
  112. package/docs/auth-howto.md +166 -0
  113. package/docs/auth.md +91 -0
  114. package/package.json +5 -3
  115. package/dist/types.d.ts +0 -253
  116. package/dist/types.js +0 -58
  117. package/dist/types.js.map +0 -1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/token.d.ts CHANGED
File without changes
package/dist/token.js CHANGED
File without changes
package/dist/token.js.map CHANGED
File without changes
package/dist/track.d.ts CHANGED
File without changes
package/dist/track.js CHANGED
File without changes
package/dist/track.js.map CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,166 @@
1
+ ## JWT Auth Flow HowTo
2
+
3
+ A short guide to setting up the JWT authentication flow using based.
4
+ An example with the info on this guide can be foud [here](https://github.com/atelier-saulx/auth-demo)
5
+
6
+ If you created an environment using the based website, the JWT auth flow template is installed by default. This template includes the `user` type schema, the public and private keys, and the default `authorize`, `login`, `logout`, and `renewToken` data functions.
7
+
8
+ These default data functions can be customized to your needs. Add them to your project from [here](https://github.com/atelier-saulx/based/tree/main/packages/auth-templates/jwt) and deploy with the [based cli `deploy` command](https://github.com/atelier-saulx/based/tree/main/packages/cli#deploy).
9
+
10
+ ### Adding a user to the database
11
+
12
+ You now need to add a user to the database so that he can log in.
13
+ There are several ways to do this, including the data editor in the Based website admin area.
14
+ We'll add it through a script from the developer's computer environment as it also shows how you can add this functionality from your own apps.
15
+
16
+ The `user` type installed by default has the following schema:
17
+
18
+ ```
19
+ ...
20
+ types: {
21
+ user: {
22
+ prefix: 'us',
23
+ fields: {
24
+ name: { type: 'string' },
25
+ email: { type: 'email' },
26
+ password: { type: 'digest' },
27
+ },
28
+ },
29
+ },
30
+ ```
31
+
32
+ It is ready to accept users with an email, name string, and hashed password.
33
+ Let's create a user from a script.
34
+
35
+ #### Setting up an apiKey
36
+
37
+ If we try to add a user now from a script, we get into a chicken and the egg issue. We don't have an authenticated user to add the user itself. You can work around this while developing using the apiKey functionality.
38
+ This feature lets us create an apikey so we can use based in utility scripts and commands using the [based cli](https://github.com/atelier-saulx/based/tree/main/packages/cli).
39
+
40
+ ```bash
41
+ $ npx based apiKeys add --name auth-demo-api-key --file ./apiKey.key
42
+ ```
43
+
44
+ This command will create an apiKey called "auth-demo-api-key" and saves its value to a file we can load from the script or use as an argument in the [based cli](https://github.com/atelier-saulx/based/tree/main/packages/cli).
45
+
46
+ **Note:** You should never store apiKeys as plain text in repositories or use them to make based connections client side.
47
+
48
+ #### Setting a user with a script
49
+
50
+ With the apiKey, we can now run a simple script to add a new user:
51
+
52
+ ```javascript
53
+ // scripts/createUser.ts
54
+
55
+ import fs from 'fs'
56
+ import based from '@based/client'
57
+
58
+ // Loads the based config file that sets up your based connection
59
+ const basedConfig = JSON.parse(fs.readFileSync('../based.json', 'utf8'))
60
+
61
+ // Loads apiKey so we can have based access from a script
62
+ // Note: apiKeys should only be used for util scripts or server/server connections
63
+ const apiKey = fs.readFileSync('../apiKey.key', 'utf8')
64
+
65
+ ;(async () => {
66
+ // Create a based client
67
+ const client = based(basedConfig)
68
+
69
+ // Authenticate client with an apiKey
70
+ await client.auth(apiKey, { isApiKey: true })
71
+
72
+ // Add our user
73
+ const { id } = await client.set({
74
+ type: 'user',
75
+ name: 'Demo User',
76
+ email: 'demo@wawa.com',
77
+ password: 'superStrongPassword',
78
+ })
79
+ console.log('Added user ' + id)
80
+
81
+ process.exit()
82
+ })()
83
+ ```
84
+
85
+ And lets run it:
86
+ ```bash
87
+ $ cd scripts
88
+ $ npx ts-node scripts/createUser.ts
89
+ Added user us1b3d5a36
90
+ ```
91
+
92
+ ## Adding login functionality to your app.
93
+
94
+ To login a user from your app, you should create a login UI, and use the based client `.login()` method to validate your user and password.
95
+ Example:
96
+
97
+ ```javascript
98
+ import based from '@based/client'
99
+
100
+ // ...
101
+
102
+
103
+ <button
104
+ onClick={async () => {
105
+ const { token, refreshToken } = await client.login({
106
+ email,
107
+ password,
108
+ })
109
+ setToken(token)
110
+ setRefreshToken(refreshToken)
111
+ }}
112
+ >
113
+ Login
114
+ </button>
115
+ ```
116
+
117
+ The `.login()` method takes the email and password supplied by the user, passes it to the `login` data function, and returns the result. Usually, a token and refreshToken if it was successful.
118
+ You should also store your token and refreshToken if you want the session to persist.
119
+
120
+ ## Authenticating the user with a persisted token
121
+
122
+ If your user already logged in and you persisted the tokens, you can authenticate it with the still valid token instead of login in.
123
+ Example:
124
+ ```javascript
125
+ // ...
126
+ if (token) {
127
+ await client.auth(token, { refreshToken })
128
+ }
129
+ ```
130
+
131
+ The `refreshToken` is also stored by the based client so it can be requested by the based servers if the token is expired and it tries to renew the token automatically.
132
+
133
+ ## Login out user
134
+
135
+ You should run the based client `.logout()` method to explicitly log out a user. This method will clear the tokens on the based client and run the `logout` data function meant to perform clean-up actions like invalidating the current refreshToken.
136
+
137
+ Example:
138
+ ```javascript
139
+ // ...
140
+ <button
141
+ onClick={async () => {
142
+ await client.logout()
143
+ setToken(null)
144
+ setRefreshToken(null)
145
+ }}
146
+ >
147
+ Logout
148
+ </button>
149
+ ```
150
+
151
+ You should also clean the stored token and refreshToken from the browser.
152
+
153
+ ## Handling automatic token renewal
154
+
155
+ The default template already has in place JWT token renewal using a refreshToken. You should however store the new token locally when this happens.
156
+ For this we have the `renewToken` based client event that we can listen.
157
+ Example:
158
+
159
+ ```javascript
160
+ // ...
161
+ const renewHandler = ({ token: newToken }: { token: string }) => {
162
+ setToken(newToken)
163
+ }
164
+
165
+ client.on('renewToken', renewHandler)
166
+ ```
package/docs/auth.md ADDED
@@ -0,0 +1,91 @@
1
+ # The Auth System
2
+
3
+ The *Based Auth* system helps developers add a security layer to their data. It does not enforce any logic itself, instead relies on a set of user-configurable *data functions* that restrict data access and implement whatever security strategy the user needs. Be it a 3rd party implementation or its own.
4
+
5
+ The central concept is that all messages through based go through a [`authorize`](https://github.com/atelier-saulx/based/blob/main/packages/client/docs/authorize.md) function that implements the security logic and decides if each specific call to data should continue or be blocked.
6
+ Within the data request, a "token" is also sent. This token is passed along to the `authorize` function for context, and it is what identifies the user in most implementations.
7
+
8
+ There are no assumptions about the "token" format. It is up to the user to choose what implementation it wants or needs. However, we provide templates for JSON Web Tokens (JWT) authorization and will soon offer session-based authentication templates. These templates provide minimal authorization strategy implementation and are meant to be tweaked and updated by the user.
9
+ Along with the `authorize` function, these templates also implement more optional functions that make a login flow more straightforward and more semantic. `login`, `logout`, and `renewToken`.
10
+
11
+ The *Based* client also catches exceptions triggered by token expiration. When this happens, it tries to call a `renewToken` function sending it a renew payload that includes, for example, the "refreshToken" used for JWT authorization flow. If that's successful and it returns a new token, it will re-request the data with the new token for transparent renewal.
12
+
13
+ ## Auth data functions
14
+
15
+ ### `authorize`
16
+
17
+ This data function runs every time the based client tries to call, get, modify or observe data.
18
+ It approves or denies the request depending on its context. See [`authorize`](https://github.com/atelier-saulx/based/blob/main/packages/client/docs/authorize.md)
19
+ Returns boolean value allowing or disallowing the connection.
20
+
21
+ Example: see [here](https://github.com/atelier-saulx/based/blob/main/packages/auth-templates/jwt/authorize/authorize.ts)
22
+
23
+ ### `login`
24
+
25
+ Called then the client [login()]() method is called. It should authenticate the user and generate the tokens. Authentication flow is up to the user.
26
+ For example, in a JWT flow, this function will validate the user in the data, sign a token and refreshToken returning them to the client.
27
+
28
+ Example: see [here](https://github.com/atelier-saulx/based/blob/main/packages/auth-templates/jwt/login/login.ts)
29
+
30
+ ### `logout`
31
+
32
+ When your app logs out a user, it should call the `client.logout()` method. This method calls this data function if it exists. It is meant to have token invalidation and any cleanup that should happen when a user logs out.
33
+
34
+ Example: see [here](https://github.com/atelier-saulx/based/blob/main/packages/auth-templates/jwt/logout/logout.ts)
35
+
36
+ ### `renewToken`
37
+
38
+ For auth flows that rely on token renewal. This data function runs when a specific error is triggered in the `authorize` function.
39
+ The result is returned to the client using the `renewToken` client event.
40
+
41
+ Example: see [here](https://github.com/atelier-saulx/based/blob/main/packages/auth-templates/jwt/renewToken/renewToken.ts)
42
+
43
+ ## Based client methods
44
+
45
+ ### `client.auth()`
46
+
47
+ Sets the token to be sent during client/server messages. The token will be passed to the `authorize` function and can be decoded from it with `based.token()`.
48
+
49
+ #### Usage
50
+ ```javascript
51
+ // Setting token
52
+ await client.auth(token)
53
+
54
+ // Setting token and refreshToken for JWT flow
55
+ await client.auth(token, {
56
+ renewOptions: { refreshToken }
57
+ })
58
+ ```
59
+
60
+ ### `client.login()`
61
+
62
+ This data function sends the email and password to the `login` data function for authentication.
63
+ Returns tokens if successful. Also, it will automatically set the returned token on the current client connection.
64
+
65
+ #### Usage
66
+ ```javascript
67
+ const tokens = await client.login({email, password})
68
+ ```
69
+
70
+ ### `client.logout()`
71
+
72
+ Clears the tokens stored by the client and calls the `logout` data function if it exists.
73
+
74
+ #### Usage
75
+ ```javascript
76
+ await client.logout()
77
+ ```
78
+
79
+ ### `client.on('renewToken', fn)`
80
+
81
+ This event is called when the renewToken data function is run. It is used to handle and persist the newly generated tokens.
82
+
83
+ #### Usage
84
+ ```javascript
85
+ client.on('renewToken', (renewTokenResult) => {})
86
+ ```
87
+
88
+
89
+ ## How to use
90
+
91
+ Check [this guide](https://github.com/atelier-saulx/based/blob/main/packages/client/docs/auth-howto.md) for an example of how the use.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@based/client",
3
- "version": "2.7.5",
3
+ "version": "2.10.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "browser": {
@@ -12,7 +12,8 @@
12
12
  "watch": "concurrently \"tsc --watch\" \"npm run buildBundle -- --watch\"",
13
13
  "test": "ava --timeout 1m --verbose",
14
14
  "watchTest": "ava --color --watch --verbose",
15
- "clean": "rimraf {.turbo,dist,node_modules}"
15
+ "clean": "rimraf {.turbo,dist,node_modules}",
16
+ "browserTest": "concurrently \"node ./test/browser/based-server.js\" \"aristotle watch -t test/browser/index.tsx -p 8005\""
16
17
  },
17
18
  "sideEffects": false,
18
19
  "ava": {
@@ -30,7 +31,7 @@
30
31
  "dependencies": {
31
32
  "@based/get-service": "2.4.3",
32
33
  "@based/graphql": "2.4.2",
33
- "@based/types": "^2.6.0",
34
+ "@based/types": "^2.7.1",
34
35
  "@saulx/diff": "^1.1.3",
35
36
  "@saulx/hash": "^1.1.0",
36
37
  "@saulx/utils": "^2.2.1",
@@ -45,6 +46,7 @@
45
46
  "@saulx/selva": "^11.0.0",
46
47
  "@saulx/utils": "^2.2.1",
47
48
  "@saulx/selva-server": "11.0.0",
49
+ "@saulx/aristotle": "^4.0.14",
48
50
  "@types/jsonwebtoken": "^8.5.6",
49
51
  "@types/node": "^17.0.23",
50
52
  "@types/ws": "^7.4.6",
package/dist/types.d.ts DELETED
@@ -1,253 +0,0 @@
1
- /// <reference types="node" />
2
- import type { GetOptions } from './selvaTypes/get';
3
- import type { SetOptions } from './selvaTypes/set';
4
- import type { Schema } from './selvaTypes/schema';
5
- import { Readable } from 'stream';
6
- export { GetOptions, SetOptions, Schema };
7
- export declare type DigestOptions = string;
8
- export declare enum RequestTypes {
9
- Subscription = 1,
10
- SubscriptionDiff = 2,
11
- SendSubscriptionData = 3,
12
- Unsubscribe = 4,
13
- Set = 5,
14
- Get = 6,
15
- Configuration = 7,
16
- GetConfiguration = 8,
17
- Call = 9,
18
- GetSubscription = 10,
19
- Delete = 11,
20
- Copy = 12,
21
- Digest = 13,
22
- Token = 14,
23
- Track = 15,
24
- Auth = 16
25
- }
26
- export declare enum AuthRequestTypes {
27
- Login = 1,
28
- Logout = 2,
29
- RenewToken = 3
30
- }
31
- export declare type Configuration = {
32
- schema: {
33
- [db: string]: Schema;
34
- };
35
- dbs: string[];
36
- };
37
- export declare type Query = GetOptions;
38
- export declare type GenericObject = {
39
- [key: string]: any;
40
- };
41
- export declare type Copy = {
42
- $id: string;
43
- db?: string;
44
- deep?: boolean;
45
- parents?: string[];
46
- excludeFields?: string[];
47
- };
48
- export declare type ErrorObject = {
49
- type: string;
50
- message: string;
51
- name?: string;
52
- query?: GenericObject;
53
- payload?: any;
54
- auth?: boolean;
55
- code?: string;
56
- };
57
- export declare type FunctionCallMessage = [RequestTypes.Call, string, number, any?];
58
- export declare type TrackMessage = [RequestTypes.Track, TrackPayload];
59
- export declare type RequestMessage<T = GenericObject> = [
60
- (RequestTypes.Set | RequestTypes.Get | RequestTypes.Configuration | RequestTypes.GetConfiguration | RequestTypes.Delete | RequestTypes.Copy | RequestTypes.Digest),
61
- number,
62
- T
63
- ];
64
- export declare type TokenMessage = [RequestTypes.Token, string?, boolean?];
65
- export declare type AuthMessage = [
66
- RequestTypes.Auth,
67
- AuthRequestTypes,
68
- number,
69
- GenericObject?
70
- ];
71
- export declare type SubscribeMessage = [
72
- RequestTypes.Subscription,
73
- number,
74
- GenericObject?,
75
- number?,
76
- (2 | 1 | 0)?,
77
- string?
78
- ];
79
- export declare type SendSubscriptionDataMessage = [
80
- RequestTypes.SendSubscriptionData,
81
- number,
82
- number?
83
- ];
84
- export declare type SendSubscriptionGetDataMessage = [
85
- RequestTypes.GetSubscription,
86
- number,
87
- GenericObject?,
88
- number?,
89
- string?
90
- ];
91
- export declare type UnsubscribeMessage = [
92
- RequestTypes.Unsubscribe,
93
- number
94
- ];
95
- export declare type SubscriptionMessage = SubscribeMessage | SendSubscriptionDataMessage | UnsubscribeMessage | SendSubscriptionGetDataMessage;
96
- export declare type Message = RequestMessage | SubscriptionMessage | FunctionCallMessage | AuthMessage;
97
- export declare type SubscriptionDiffData = [
98
- RequestTypes.SubscriptionDiff,
99
- number,
100
- GenericObject,
101
- [
102
- number,
103
- number
104
- ]
105
- ];
106
- export declare type SubscriptionData = [
107
- RequestTypes.Subscription,
108
- number,
109
- GenericObject,
110
- number?,
111
- ErrorObject?
112
- ];
113
- export declare type RequestData = [
114
- (RequestTypes.Set | RequestTypes.Get | RequestTypes.Configuration | RequestTypes.GetConfiguration | RequestTypes.Call | RequestTypes.Delete | RequestTypes.Copy | RequestTypes.Digest),
115
- number,
116
- any,
117
- ErrorObject?
118
- ];
119
- export declare type AuthorizedData = [RequestTypes.Token, number[], boolean?];
120
- export declare type AuthData = [
121
- RequestTypes.Auth,
122
- number,
123
- GenericObject,
124
- ErrorObject?
125
- ];
126
- export declare type ResponseData = SubscriptionDiffData | SubscriptionData | RequestData | AuthorizedData | AuthData;
127
- export declare type TrackPayload = {
128
- t: string;
129
- u?: 1;
130
- s?: 1;
131
- e?: 1;
132
- r?: 1;
133
- o?: TrackOpts;
134
- };
135
- export declare type TrackOpts = {
136
- amount?: number;
137
- };
138
- export declare type SendTokenOptions = {
139
- isBasedUser?: boolean;
140
- isApiKey?: boolean;
141
- refreshToken?: string;
142
- };
143
- export declare type AnalyticsResult = {
144
- all: {
145
- total: number;
146
- geo?: {
147
- [isoCode: string]: number;
148
- };
149
- };
150
- unique: {
151
- total: number;
152
- geo?: {
153
- [isoCode: string]: number;
154
- };
155
- };
156
- active: {
157
- total: number;
158
- max: number;
159
- geo?: {
160
- [isoCode: string]: number;
161
- };
162
- };
163
- };
164
- export declare type AnalyticsHistoryResult = {
165
- all: {
166
- total: [number, number][];
167
- geo?: {
168
- [isoCode: string]: [number, number][];
169
- };
170
- };
171
- unique: {
172
- total: [number, number][];
173
- geo?: {
174
- [isoCode: string]: [number, number][];
175
- };
176
- };
177
- active: {
178
- total: [number, number][];
179
- geo?: {
180
- [isoCode: string]: [number, number][];
181
- };
182
- };
183
- };
184
- export declare type AnalyticsTypes = string[];
185
- export declare type AnalyticsTypesOpts = {
186
- type?: string;
187
- $types: true;
188
- };
189
- export declare function isAnalyticsTypesOpts(opts: AnalyticsOpts | AnalyticsTypesOpts): opts is AnalyticsTypesOpts;
190
- export declare function isAnalyticsHistoryOpts(opts: AnalyticsOpts | AnalyticsTypesOpts): opts is AnalyticsHistoryOpts;
191
- export declare type AnalyticsOpts = {
192
- type: string;
193
- params?: {
194
- [key: string]: number | string | boolean;
195
- };
196
- $geo?: string[] | boolean;
197
- };
198
- export declare type AnalyticsHistoryOpts = {
199
- type: string;
200
- params?: {
201
- [key: string]: number | string | boolean;
202
- };
203
- $geo?: string[] | boolean;
204
- $history: boolean | number;
205
- };
206
- export declare type LoginOpts = {
207
- email: string;
208
- password: string;
209
- };
210
- export declare type RenewTokenOpts = {
211
- refreshToken: string;
212
- };
213
- export declare type FileUploadOptions = {
214
- contents: Buffer | ArrayBuffer | string | File | Blob;
215
- mimeType?: string;
216
- name?: string;
217
- url?: string | (() => Promise<string>);
218
- id?: string;
219
- raw?: boolean;
220
- parents?: string[];
221
- functionName?: string;
222
- };
223
- export declare type FileUploadStream = {
224
- contents: Readable;
225
- mimeType?: string;
226
- extension?: string;
227
- size: number;
228
- name?: string;
229
- url?: string | (() => Promise<string>);
230
- id?: string;
231
- raw?: boolean;
232
- parents?: string[];
233
- functionName?: string;
234
- };
235
- export declare type FileUploadPath = {
236
- path: string;
237
- mimeType?: string;
238
- extension?: string;
239
- name?: string;
240
- url?: string | (() => Promise<string>);
241
- id?: string;
242
- raw?: boolean;
243
- parents?: string[];
244
- functionName?: string;
245
- };
246
- export declare type FileUploadSrc = {
247
- src: string;
248
- mimeType?: string;
249
- name?: string;
250
- id?: string;
251
- parents?: string[];
252
- size?: number;
253
- };