entropic-bond 1.48.1 → 1.50.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/.github/workflows/release.yml +26 -0
- package/CHANGELOG.md +1151 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +94 -0
- package/docs/classes/Auth.md +391 -0
- package/docs/classes/AuthMock.md +278 -0
- package/docs/classes/AuthService.md +188 -0
- package/docs/classes/CloudFunctions.md +123 -0
- package/docs/classes/CloudFunctionsMock.md +97 -0
- package/docs/classes/CloudStorage.md +215 -0
- package/docs/classes/DataSource.md +248 -0
- package/docs/classes/EntropicComponent.md +666 -0
- package/docs/classes/JsonDataSource.md +328 -0
- package/docs/classes/MockCloudStorage.md +279 -0
- package/docs/classes/Model.md +274 -0
- package/docs/classes/Observable.md +120 -0
- package/docs/classes/Persistent.md +420 -0
- package/docs/classes/ServerAuth.md +211 -0
- package/docs/classes/ServerAuthMock.md +176 -0
- package/docs/classes/ServerAuthService.md +130 -0
- package/docs/classes/Store.md +218 -0
- package/docs/classes/StoredFile.md +636 -0
- package/docs/enums/StoredFileEvent.md +41 -0
- package/docs/interfaces/AuthError.md +30 -0
- package/docs/interfaces/CloudFunctionsService.md +69 -0
- package/docs/interfaces/Collection.md +13 -0
- package/docs/interfaces/CustomCredentials.md +7 -0
- package/docs/interfaces/DocumentReference.md +49 -0
- package/docs/interfaces/JsonRawData.md +7 -0
- package/docs/interfaces/SignData.md +63 -0
- package/docs/interfaces/StoreParams.md +52 -0
- package/docs/interfaces/StoredFileChange.md +41 -0
- package/docs/interfaces/UploadControl.md +90 -0
- package/docs/interfaces/UserCredentials.md +113 -0
- package/docs/interfaces/Values.md +17 -0
- package/docs/modules.md +1273 -0
- package/package.json +23 -19
- package/src/auth/auth-mock.spec.ts +168 -0
- package/src/auth/auth-mock.ts +129 -0
- package/src/auth/auth.ts +185 -0
- package/src/auth/user-auth-types.ts +21 -0
- package/src/cloud-functions/cloud-functions-mock.spec.ts +136 -0
- package/src/cloud-functions/cloud-functions-mock.ts +23 -0
- package/src/cloud-functions/cloud-functions.ts +83 -0
- package/src/cloud-storage/cloud-storage.spec.ts +207 -0
- package/src/cloud-storage/cloud-storage.ts +60 -0
- package/src/cloud-storage/mock-cloud-storage.ts +72 -0
- package/src/cloud-storage/stored-file.ts +102 -0
- package/src/index.ts +19 -0
- package/src/observable/observable.spec.ts +105 -0
- package/src/observable/observable.ts +67 -0
- package/src/persistent/entropic-component.spec.ts +143 -0
- package/src/persistent/entropic-component.ts +135 -0
- package/src/persistent/persistent.spec.ts +828 -0
- package/src/persistent/persistent.ts +650 -0
- package/src/server-auth/server-auth-mock.spec.ts +53 -0
- package/src/server-auth/server-auth-mock.ts +45 -0
- package/src/server-auth/server-auth.ts +49 -0
- package/src/store/data-source.ts +186 -0
- package/src/store/json-data-source.spec.ts +100 -0
- package/src/store/json-data-source.ts +256 -0
- package/src/store/mocks/mock-data.json +155 -0
- package/src/store/mocks/test-user.ts +122 -0
- package/src/store/model.spec.ts +659 -0
- package/src/store/model.ts +462 -0
- package/src/store/store.spec.ts +30 -0
- package/src/store/store.ts +113 -0
- package/src/types/utility-types.spec.ts +117 -0
- package/src/types/utility-types.ts +116 -0
- package/src/utils/test-utils/test-person.ts +44 -0
- package/src/utils/utils.spec.ts +95 -0
- package/{lib/utils/utils.d.ts → src/utils/utils.ts} +34 -10
- package/tsconfig-build.json +7 -0
- package/tsconfig-cjs.json +9 -0
- package/tsconfig.json +33 -0
- package/vite.config.ts +22 -0
- package/lib/auth/auth-mock.d.ts +0 -21
- package/lib/auth/auth-mock.js +0 -108
- package/lib/auth/auth-mock.js.map +0 -1
- package/lib/auth/auth.d.ts +0 -129
- package/lib/auth/auth.js +0 -146
- package/lib/auth/auth.js.map +0 -1
- package/lib/auth/user-auth-types.d.ts +0 -19
- package/lib/auth/user-auth-types.js +0 -3
- package/lib/auth/user-auth-types.js.map +0 -1
- package/lib/cloud-functions/cloud-functions-mock.d.ts +0 -11
- package/lib/cloud-functions/cloud-functions-mock.js +0 -19
- package/lib/cloud-functions/cloud-functions-mock.js.map +0 -1
- package/lib/cloud-functions/cloud-functions.d.ts +0 -19
- package/lib/cloud-functions/cloud-functions.js +0 -64
- package/lib/cloud-functions/cloud-functions.js.map +0 -1
- package/lib/cloud-storage/cloud-storage.d.ts +0 -24
- package/lib/cloud-storage/cloud-storage.js +0 -37
- package/lib/cloud-storage/cloud-storage.js.map +0 -1
- package/lib/cloud-storage/mock-cloud-storage.d.ts +0 -20
- package/lib/cloud-storage/mock-cloud-storage.js +0 -68
- package/lib/cloud-storage/mock-cloud-storage.js.map +0 -1
- package/lib/cloud-storage/stored-file.d.ts +0 -39
- package/lib/cloud-storage/stored-file.js +0 -106
- package/lib/cloud-storage/stored-file.js.map +0 -1
- package/lib/index.d.ts +0 -19
- package/lib/index.js +0 -36
- package/lib/index.js.map +0 -1
- package/lib/observable/observable.d.ts +0 -52
- package/lib/observable/observable.js +0 -66
- package/lib/observable/observable.js.map +0 -1
- package/lib/persistent/entropic-component.d.ts +0 -76
- package/lib/persistent/entropic-component.js +0 -109
- package/lib/persistent/entropic-component.js.map +0 -1
- package/lib/persistent/persistent.d.ts +0 -281
- package/lib/persistent/persistent.js +0 -539
- package/lib/persistent/persistent.js.map +0 -1
- package/lib/server-auth/server-auth-mock.d.ts +0 -12
- package/lib/server-auth/server-auth-mock.js +0 -39
- package/lib/server-auth/server-auth-mock.js.map +0 -1
- package/lib/server-auth/server-auth.d.ts +0 -24
- package/lib/server-auth/server-auth.js +0 -36
- package/lib/server-auth/server-auth.js.map +0 -1
- package/lib/store/data-source.d.ts +0 -137
- package/lib/store/data-source.js +0 -62
- package/lib/store/data-source.js.map +0 -1
- package/lib/store/json-data-source.d.ts +0 -68
- package/lib/store/json-data-source.js +0 -199
- package/lib/store/json-data-source.js.map +0 -1
- package/lib/store/mocks/test-user.d.ts +0 -49
- package/lib/store/mocks/test-user.js +0 -135
- package/lib/store/mocks/test-user.js.map +0 -1
- package/lib/store/model.d.ts +0 -238
- package/lib/store/model.js +0 -417
- package/lib/store/model.js.map +0 -1
- package/lib/store/store.d.ts +0 -62
- package/lib/store/store.js +0 -102
- package/lib/store/store.js.map +0 -1
- package/lib/types/utility-types.d.ts +0 -45
- package/lib/types/utility-types.js +0 -3
- package/lib/types/utility-types.js.map +0 -1
- package/lib/utils/test-utils/test-person.d.ts +0 -33
- package/lib/utils/test-utils/test-person.js +0 -25
- package/lib/utils/test-utils/test-person.js.map +0 -1
- package/lib/utils/utils.js +0 -76
- package/lib/utils/utils.js.map +0 -1
package/docs/.nojekyll
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
entropic-bond / [Exports](modules.md)
|
|
2
|
+
|
|
3
|
+
# Entropic Bond
|
|
4
|
+
|
|
5
|
+
> Tidy up your messy components
|
|
6
|
+
|
|
7
|
+
**Entropic Bond** helps your _TypeScript_ software development, both in the frontend and the backend. It is composed by several abstractions that make your code fully decoupled from the database, authorization service or cloud storage provider yet easy to use. In addition, it offers an observer based architecture to intercommunicate your business logic entities efficiently.
|
|
8
|
+
|
|
9
|
+
## Who needs to focus on a unique backend provider
|
|
10
|
+
|
|
11
|
+
**Entropic Bond** is designed with the serverless and NoSQL models in mind. This doesn't mean you cannot use it in such scenarios. Moreover, it is an excellent tool to develop _Functions as a Service_ (FaaS). With **Entropic Bond**, you just forget about those implementation details. You only need to focus on developing your domain model.
|
|
12
|
+
|
|
13
|
+
## Who needs a global state
|
|
14
|
+
|
|
15
|
+
**Entropic Bond** removes the need to maintain a global state. The underlying architecture is designed in a way that the state is maintained at entity level and the relationship between the entities is provided by a notification infrastructure.
|
|
16
|
+
|
|
17
|
+
## How to use
|
|
18
|
+
|
|
19
|
+
Typically, you will derive all your business logic entities from the `EntropicComponent` class. This class provides two main functionalities; persistence and observability.
|
|
20
|
+
|
|
21
|
+
### API
|
|
22
|
+
|
|
23
|
+
You can find the API documentation [here](docs/modules.md).
|
|
24
|
+
|
|
25
|
+
### Persistence
|
|
26
|
+
|
|
27
|
+
The persistence mechanism allows defining which entities and which properties of those entities should be stored in the database. To make an entity persistent, it should derive from the `EntropicComponent` class or the `Persistent` class.
|
|
28
|
+
|
|
29
|
+
In order to allow the persistence mechanism to automatically instantiate entities from the database, you should use the `@registerPersistentClass` decorator passing the class name as a parameter.
|
|
30
|
+
|
|
31
|
+
The properties or attributes that you want to be streamed should be preceded by the `@persistent` decorator in the attribute declaration. The property name must be private and prefixed with an underscore (_). Access to the public attributes should be done by the use of accessors.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
@registerPersistentClass( 'MyEntity' )
|
|
35
|
+
class MyEntity extends EntropicBond {
|
|
36
|
+
@persistent private _persistentProp1: string
|
|
37
|
+
@persistent private _persistentProp2: boolean
|
|
38
|
+
@persistent private _persistentProp3: AnotherPersistentObject
|
|
39
|
+
@persistent private _persistentProp4: number[]
|
|
40
|
+
|
|
41
|
+
private _nonPersistentProp: unknown
|
|
42
|
+
|
|
43
|
+
// accessors go here ...
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Storing and querying the persistent entities
|
|
48
|
+
|
|
49
|
+
The database abstraction is provided by the `Store` object. To learn how to set up a concrete database, [see below](setup_the_database_access).
|
|
50
|
+
|
|
51
|
+
The `Store.getModel` method will return an object with methods to access the database.
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
let foundEntity: MyEntity
|
|
55
|
+
const myEntity = new MyEntity()
|
|
56
|
+
const entityModel = Store.getModel<MyEntity>( 'MyEntity' )
|
|
57
|
+
|
|
58
|
+
// fill myEntity object with data here ...
|
|
59
|
+
|
|
60
|
+
await entityModel.save( myEntity ) // saves myEntity in the database
|
|
61
|
+
|
|
62
|
+
foundEntity = await entityModel.findById( '0340d-349ab' ) // retrieves from database
|
|
63
|
+
|
|
64
|
+
foundEntity = await entityModel.find().
|
|
65
|
+
.where( 'persistentProp1', '==', 'foo' )
|
|
66
|
+
.where( 'persistentProp2', '==', true )
|
|
67
|
+
.limit( 10 )
|
|
68
|
+
.orderBy( 'persistentProp1', 'desc' )
|
|
69
|
+
.get() // retrieves from database
|
|
70
|
+
|
|
71
|
+
entityModel.delete( '0340d-349ab' ) // deletes from database
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Set up the database access
|
|
75
|
+
|
|
76
|
+
The database access is encapsulated in a `DataSource` object. A concrete implementation of a _JSON_ `DataSource` is provided as `JsonDataSource`. You can use this implementation for testing purposes.
|
|
77
|
+
|
|
78
|
+
Currently, there is an official plugin to connect to a **Firebase** _Firestore_ database. To install the plugin, run:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
npm i entropic-bond-firebase
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
You can develop new plugins following the [plugin developer's](plugin_development) section.
|
|
85
|
+
|
|
86
|
+
You should instantiate the concrete implementation of the `DataSource` and pass it to the `useDataSource` method of the `Store` object.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
Store.useDataSource( new JsonDataSource() )
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Observability
|
|
93
|
+
|
|
94
|
+
### Auth
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
[entropic-bond](../README.md) / [Exports](../modules.md) / Auth
|
|
2
|
+
|
|
3
|
+
# Class: Auth
|
|
4
|
+
|
|
5
|
+
The Auth class is a singleton that provides a unified interface to the authentication service.
|
|
6
|
+
You should register an authentication service by using `Auth.useAuthService`
|
|
7
|
+
method before using the Auth class.
|
|
8
|
+
|
|
9
|
+
## Hierarchy
|
|
10
|
+
|
|
11
|
+
- [`AuthService`](AuthService.md)
|
|
12
|
+
|
|
13
|
+
↳ **`Auth`**
|
|
14
|
+
|
|
15
|
+
## Table of contents
|
|
16
|
+
|
|
17
|
+
### Constructors
|
|
18
|
+
|
|
19
|
+
- [constructor](Auth.md#constructor)
|
|
20
|
+
|
|
21
|
+
### Properties
|
|
22
|
+
|
|
23
|
+
- [error](Auth.md#error)
|
|
24
|
+
|
|
25
|
+
### Accessors
|
|
26
|
+
|
|
27
|
+
- [instance](Auth.md#instance)
|
|
28
|
+
|
|
29
|
+
### Methods
|
|
30
|
+
|
|
31
|
+
- [linkAdditionalProvider](Auth.md#linkadditionalprovider)
|
|
32
|
+
- [login](Auth.md#login)
|
|
33
|
+
- [logout](Auth.md#logout)
|
|
34
|
+
- [onAuthStateChange](Auth.md#onauthstatechange)
|
|
35
|
+
- [removeAuthStateChange](Auth.md#removeauthstatechange)
|
|
36
|
+
- [resetEmailPassword](Auth.md#resetemailpassword)
|
|
37
|
+
- [signUp](Auth.md#signup)
|
|
38
|
+
- [unlinkProvider](Auth.md#unlinkprovider)
|
|
39
|
+
- [useAuthService](Auth.md#useauthservice)
|
|
40
|
+
|
|
41
|
+
## Constructors
|
|
42
|
+
|
|
43
|
+
### constructor
|
|
44
|
+
|
|
45
|
+
• `Protected` **new Auth**()
|
|
46
|
+
|
|
47
|
+
#### Overrides
|
|
48
|
+
|
|
49
|
+
[AuthService](AuthService.md).[constructor](AuthService.md#constructor)
|
|
50
|
+
|
|
51
|
+
#### Defined in
|
|
52
|
+
|
|
53
|
+
[auth/auth.ts:39](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L39)
|
|
54
|
+
|
|
55
|
+
## Properties
|
|
56
|
+
|
|
57
|
+
### error
|
|
58
|
+
|
|
59
|
+
▪ `Static` **error**: `Object`
|
|
60
|
+
|
|
61
|
+
#### Type declaration
|
|
62
|
+
|
|
63
|
+
| Name | Type |
|
|
64
|
+
| :------ | :------ |
|
|
65
|
+
| `shouldBeRegistered` | `string` |
|
|
66
|
+
|
|
67
|
+
#### Defined in
|
|
68
|
+
|
|
69
|
+
[auth/auth.ts:37](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L37)
|
|
70
|
+
|
|
71
|
+
## Accessors
|
|
72
|
+
|
|
73
|
+
### instance
|
|
74
|
+
|
|
75
|
+
• `Static` `get` **instance**(): [`Auth`](Auth.md)
|
|
76
|
+
|
|
77
|
+
The instance of the Auth class
|
|
78
|
+
|
|
79
|
+
#### Returns
|
|
80
|
+
|
|
81
|
+
[`Auth`](Auth.md)
|
|
82
|
+
|
|
83
|
+
the authentication service
|
|
84
|
+
|
|
85
|
+
#### Defined in
|
|
86
|
+
|
|
87
|
+
[auth/auth.ts:63](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L63)
|
|
88
|
+
|
|
89
|
+
## Methods
|
|
90
|
+
|
|
91
|
+
### linkAdditionalProvider
|
|
92
|
+
|
|
93
|
+
▸ **linkAdditionalProvider**(`provider`): `Promise`<`unknown`\>
|
|
94
|
+
|
|
95
|
+
Links an additional authentication provider to the authenticated user.
|
|
96
|
+
|
|
97
|
+
**`Example`**
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
// Link a Google account to the auth service
|
|
101
|
+
Auth.instance.linkAdditionalProvider({ authProvider: 'google' })
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Parameters
|
|
105
|
+
|
|
106
|
+
| Name | Type | Description |
|
|
107
|
+
| :------ | :------ | :------ |
|
|
108
|
+
| `provider` | [`AuthProvider`](../modules.md#authprovider) | the provider to be linked |
|
|
109
|
+
|
|
110
|
+
#### Returns
|
|
111
|
+
|
|
112
|
+
`Promise`<`unknown`\>
|
|
113
|
+
|
|
114
|
+
a promise that resolves when the process is done
|
|
115
|
+
|
|
116
|
+
#### Overrides
|
|
117
|
+
|
|
118
|
+
[AuthService](AuthService.md).[linkAdditionalProvider](AuthService.md#linkadditionalprovider)
|
|
119
|
+
|
|
120
|
+
#### Defined in
|
|
121
|
+
|
|
122
|
+
[auth/auth.ts:148](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L148)
|
|
123
|
+
|
|
124
|
+
___
|
|
125
|
+
|
|
126
|
+
### login
|
|
127
|
+
|
|
128
|
+
▸ **login**<`T`\>(`singData`): `Promise`<[`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>\>
|
|
129
|
+
|
|
130
|
+
Logs in an existing user
|
|
131
|
+
|
|
132
|
+
**`Example`**
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
// Log in an existing user with email and password
|
|
136
|
+
Auth.instance.login({ authProvider: 'email', email: 'john@test.com', password: '123456' })
|
|
137
|
+
// Log in an existing user with a Google account
|
|
138
|
+
Auth.instance.login({ authProvider: 'google'})
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### Type parameters
|
|
142
|
+
|
|
143
|
+
| Name | Type |
|
|
144
|
+
| :------ | :------ |
|
|
145
|
+
| `T` | extends `Object` |
|
|
146
|
+
|
|
147
|
+
#### Parameters
|
|
148
|
+
|
|
149
|
+
| Name | Type | Description |
|
|
150
|
+
| :------ | :------ | :------ |
|
|
151
|
+
| `singData` | [`SignData`](../interfaces/SignData.md) | the data to be used to log in the user |
|
|
152
|
+
|
|
153
|
+
#### Returns
|
|
154
|
+
|
|
155
|
+
`Promise`<[`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>\>
|
|
156
|
+
|
|
157
|
+
a promise that resolves to the user credentials
|
|
158
|
+
|
|
159
|
+
#### Overrides
|
|
160
|
+
|
|
161
|
+
[AuthService](AuthService.md).[login](AuthService.md#login)
|
|
162
|
+
|
|
163
|
+
#### Defined in
|
|
164
|
+
|
|
165
|
+
[auth/auth.ts:91](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L91)
|
|
166
|
+
|
|
167
|
+
___
|
|
168
|
+
|
|
169
|
+
### logout
|
|
170
|
+
|
|
171
|
+
▸ **logout**(): `Promise`<`void`\>
|
|
172
|
+
|
|
173
|
+
Logs out the current user
|
|
174
|
+
|
|
175
|
+
#### Returns
|
|
176
|
+
|
|
177
|
+
`Promise`<`void`\>
|
|
178
|
+
|
|
179
|
+
a promise that resolves when the user is logged out
|
|
180
|
+
|
|
181
|
+
#### Overrides
|
|
182
|
+
|
|
183
|
+
[AuthService](AuthService.md).[logout](AuthService.md#logout)
|
|
184
|
+
|
|
185
|
+
#### Defined in
|
|
186
|
+
|
|
187
|
+
[auth/auth.ts:99](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L99)
|
|
188
|
+
|
|
189
|
+
___
|
|
190
|
+
|
|
191
|
+
### onAuthStateChange
|
|
192
|
+
|
|
193
|
+
▸ **onAuthStateChange**<`T`\>(`onChange`): [`Unsubscriber`](../modules.md#unsubscriber)
|
|
194
|
+
|
|
195
|
+
Adds a listener to be called when the authentication state changes.
|
|
196
|
+
|
|
197
|
+
**`Example`**
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
// Add a listener to be called when the authentication state changes
|
|
201
|
+
const removeListener = Auth.instance.onAuthStateChange( userCredentials => {
|
|
202
|
+
if ( userCredentials ) {
|
|
203
|
+
// The user is logged in
|
|
204
|
+
} else {
|
|
205
|
+
// The user is logged out
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
#### Type parameters
|
|
211
|
+
|
|
212
|
+
| Name | Type |
|
|
213
|
+
| :------ | :------ |
|
|
214
|
+
| `T` | extends `Object` |
|
|
215
|
+
|
|
216
|
+
#### Parameters
|
|
217
|
+
|
|
218
|
+
| Name | Type | Description |
|
|
219
|
+
| :------ | :------ | :------ |
|
|
220
|
+
| `onChange` | (`userCredentials`: [`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>) => `void` | the listener to be called when the authentication state changes. The listener is called with the user credentials as a parameter. If the user is logged out, the listener is called with `undefined` as a parameter. |
|
|
221
|
+
|
|
222
|
+
#### Returns
|
|
223
|
+
|
|
224
|
+
[`Unsubscriber`](../modules.md#unsubscriber)
|
|
225
|
+
|
|
226
|
+
a function to remove the listener
|
|
227
|
+
|
|
228
|
+
#### Overrides
|
|
229
|
+
|
|
230
|
+
[AuthService](AuthService.md).[onAuthStateChange](AuthService.md#onauthstatechange)
|
|
231
|
+
|
|
232
|
+
#### Defined in
|
|
233
|
+
|
|
234
|
+
[auth/auth.ts:128](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L128)
|
|
235
|
+
|
|
236
|
+
___
|
|
237
|
+
|
|
238
|
+
### removeAuthStateChange
|
|
239
|
+
|
|
240
|
+
▸ **removeAuthStateChange**<`T`\>(`onChange`): `void`
|
|
241
|
+
|
|
242
|
+
Removes a listener that was added by `onAuthStateChange` method.
|
|
243
|
+
|
|
244
|
+
#### Type parameters
|
|
245
|
+
|
|
246
|
+
| Name | Type |
|
|
247
|
+
| :------ | :------ |
|
|
248
|
+
| `T` | extends `Object` |
|
|
249
|
+
|
|
250
|
+
#### Parameters
|
|
251
|
+
|
|
252
|
+
| Name | Type | Description |
|
|
253
|
+
| :------ | :------ | :------ |
|
|
254
|
+
| `onChange` | (`userCredentials`: [`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>) => `void` | the listener to be removed |
|
|
255
|
+
|
|
256
|
+
#### Returns
|
|
257
|
+
|
|
258
|
+
`void`
|
|
259
|
+
|
|
260
|
+
#### Defined in
|
|
261
|
+
|
|
262
|
+
[auth/auth.ts:136](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L136)
|
|
263
|
+
|
|
264
|
+
___
|
|
265
|
+
|
|
266
|
+
### resetEmailPassword
|
|
267
|
+
|
|
268
|
+
▸ **resetEmailPassword**(`email`): `Promise`<`void`\>
|
|
269
|
+
|
|
270
|
+
Resets the password associated with the email.
|
|
271
|
+
|
|
272
|
+
#### Parameters
|
|
273
|
+
|
|
274
|
+
| Name | Type | Description |
|
|
275
|
+
| :------ | :------ | :------ |
|
|
276
|
+
| `email` | `string` | the email address of the user to reset the password |
|
|
277
|
+
|
|
278
|
+
#### Returns
|
|
279
|
+
|
|
280
|
+
`Promise`<`void`\>
|
|
281
|
+
|
|
282
|
+
a promise that resolves when the process is done
|
|
283
|
+
|
|
284
|
+
#### Overrides
|
|
285
|
+
|
|
286
|
+
[AuthService](AuthService.md).[resetEmailPassword](AuthService.md#resetemailpassword)
|
|
287
|
+
|
|
288
|
+
#### Defined in
|
|
289
|
+
|
|
290
|
+
[auth/auth.ts:108](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L108)
|
|
291
|
+
|
|
292
|
+
___
|
|
293
|
+
|
|
294
|
+
### signUp
|
|
295
|
+
|
|
296
|
+
▸ **signUp**<`T`\>(`singData`): `Promise`<[`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>\>
|
|
297
|
+
|
|
298
|
+
Signs up a new user
|
|
299
|
+
|
|
300
|
+
**`Example`**
|
|
301
|
+
|
|
302
|
+
```ts
|
|
303
|
+
// Sign up a new user with email and password
|
|
304
|
+
Auth.instance.signUp({ authProvider: 'email', email: 'john@test.com', password: '123456' })
|
|
305
|
+
// Sign up a new user with a Google account
|
|
306
|
+
Auth.instance.signUp({ authProvider: 'google'})
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
#### Type parameters
|
|
310
|
+
|
|
311
|
+
| Name | Type |
|
|
312
|
+
| :------ | :------ |
|
|
313
|
+
| `T` | extends `Object` |
|
|
314
|
+
|
|
315
|
+
#### Parameters
|
|
316
|
+
|
|
317
|
+
| Name | Type | Description |
|
|
318
|
+
| :------ | :------ | :------ |
|
|
319
|
+
| `singData` | [`SignData`](../interfaces/SignData.md) | the data to be used to sign up the user |
|
|
320
|
+
|
|
321
|
+
#### Returns
|
|
322
|
+
|
|
323
|
+
`Promise`<[`UserCredentials`](../interfaces/UserCredentials.md)<`T`\>\>
|
|
324
|
+
|
|
325
|
+
a promise that resolves to the user credentials
|
|
326
|
+
|
|
327
|
+
#### Overrides
|
|
328
|
+
|
|
329
|
+
[AuthService](AuthService.md).[signUp](AuthService.md#signup)
|
|
330
|
+
|
|
331
|
+
#### Defined in
|
|
332
|
+
|
|
333
|
+
[auth/auth.ts:77](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L77)
|
|
334
|
+
|
|
335
|
+
___
|
|
336
|
+
|
|
337
|
+
### unlinkProvider
|
|
338
|
+
|
|
339
|
+
▸ **unlinkProvider**(`provider`): `Promise`<`unknown`\>
|
|
340
|
+
|
|
341
|
+
Unlinks an authentication provider from the authenticated user.
|
|
342
|
+
|
|
343
|
+
**`Example`**
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
// Unlink the Google account from the auth service
|
|
347
|
+
Auth.instance.unlinkProvider({ authProvider: 'google' })
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
#### Parameters
|
|
351
|
+
|
|
352
|
+
| Name | Type | Description |
|
|
353
|
+
| :------ | :------ | :------ |
|
|
354
|
+
| `provider` | [`AuthProvider`](../modules.md#authprovider) | the provider to be unlinked |
|
|
355
|
+
|
|
356
|
+
#### Returns
|
|
357
|
+
|
|
358
|
+
`Promise`<`unknown`\>
|
|
359
|
+
|
|
360
|
+
a promise that resolves when the process is done
|
|
361
|
+
|
|
362
|
+
#### Overrides
|
|
363
|
+
|
|
364
|
+
[AuthService](AuthService.md).[unlinkProvider](AuthService.md#unlinkprovider)
|
|
365
|
+
|
|
366
|
+
#### Defined in
|
|
367
|
+
|
|
368
|
+
[auth/auth.ts:160](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L160)
|
|
369
|
+
|
|
370
|
+
___
|
|
371
|
+
|
|
372
|
+
### useAuthService
|
|
373
|
+
|
|
374
|
+
▸ `Static` **useAuthService**(`authService`): `void`
|
|
375
|
+
|
|
376
|
+
Registers an authentication service to be used by the Auth class.
|
|
377
|
+
You need to register an authentication service before using the Auth class.
|
|
378
|
+
|
|
379
|
+
#### Parameters
|
|
380
|
+
|
|
381
|
+
| Name | Type | Description |
|
|
382
|
+
| :------ | :------ | :------ |
|
|
383
|
+
| `authService` | [`AuthService`](AuthService.md) | the authentication service to be used by the Auth class |
|
|
384
|
+
|
|
385
|
+
#### Returns
|
|
386
|
+
|
|
387
|
+
`void`
|
|
388
|
+
|
|
389
|
+
#### Defined in
|
|
390
|
+
|
|
391
|
+
[auth/auth.ts:52](https://github.com/entropic-bond/entropic-bond/blob/c9dd385/src/auth/auth.ts#L52)
|