Skip to content

Commit f950d32

Browse files
committed
dart 3.7 support
1 parent 7651445 commit f950d32

45 files changed

Lines changed: 830 additions & 505 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

auth_node/lib/src/node/auth_node.dart

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ class AuthServiceNode
2222
return getInstance(app, () {
2323
assert(app is AppNode, 'invalid firebase app type');
2424
final appNode = app as AppNode;
25-
return AuthNode(this, appNode,
26-
node.firebaseAdminAuthModule.getAuth(appNode.nativeInstance));
25+
return AuthNode(
26+
this,
27+
appNode,
28+
node.firebaseAdminAuthModule.getAuth(appNode.nativeInstance),
29+
);
2730
});
2831
}
2932

@@ -163,7 +166,8 @@ class DecodedIdTokenNode implements DecodedIdToken {
163166
}
164167

165168
ListUsersResult? wrapListUsersResult(
166-
node.ListUsersResult? nativeListUsersResult) =>
169+
node.ListUsersResult? nativeListUsersResult,
170+
) =>
167171
nativeListUsersResult != null
168172
? ListUsersResultNode(nativeListUsersResult)
169173
: null;
@@ -191,10 +195,13 @@ class AuthNode with FirebaseAppProductMixin<FirebaseAuth>, FirebaseAuthMixin {
191195
///
192196
/// This is used to retrieve all the users of a specified project in batches.
193197
@override
194-
Future<ListUsersResult> listUsers(
195-
{int? maxResults, String? pageToken}) async {
198+
Future<ListUsersResult> listUsers({
199+
int? maxResults,
200+
String? pageToken,
201+
}) async {
196202
return wrapListUsersResult(
197-
await nativeInstance.listUsers(maxResults, pageToken))!;
203+
await nativeInstance.listUsers(maxResults, pageToken),
204+
)!;
198205
}
199206

200207
@override
@@ -214,10 +221,14 @@ class AuthNode with FirebaseAppProductMixin<FirebaseAuth>, FirebaseAuthMixin {
214221
throw UnsupportedError('onCurrentUser not supported for node');
215222

216223
@override
217-
Future<DecodedIdToken> verifyIdToken(String idToken,
218-
{bool? checkRevoked}) async {
219-
var nativeDecodedIdToken =
220-
await nativeInstance.verifyIdToken(idToken, checkRevoked);
224+
Future<DecodedIdToken> verifyIdToken(
225+
String idToken, {
226+
bool? checkRevoked,
227+
}) async {
228+
var nativeDecodedIdToken = await nativeInstance.verifyIdToken(
229+
idToken,
230+
checkRevoked,
231+
);
221232
return DecodedIdTokenNode(nativeDecodedIdToken);
222233
}
223234

auth_node/lib/src/node/auth_node_js_interop.dart

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ extension AuthExt on Auth {
3838
/// and payload.
3939
@js.JS('createCustomToken')
4040
external js.JSPromise<js.JSString> jsCreateCustomToken(
41-
String uid, js.JSObject? developerClaims);
41+
String uid,
42+
js.JSObject? developerClaims,
43+
);
4244

4345
/// Creates a new user.
4446
///
@@ -82,8 +84,10 @@ extension AuthExt on Auth {
8284
/// Returns a js.JSPromise that resolves with the current batch of downloaded users
8385
/// and the next page token as an instance of [ListUsersResult].
8486
@js.JS('listUsers')
85-
external js.JSPromise<ListUsersResult> jsListUsers(
86-
[int? maxResults, String? pageToken]);
87+
external js.JSPromise<ListUsersResult> jsListUsers([
88+
int? maxResults,
89+
String? pageToken,
90+
]);
8791

8892
/// Revokes all refresh tokens for an existing user.
8993
///
@@ -115,23 +119,29 @@ extension AuthExt on Auth {
115119
/// Returns a js.JSPromise containing `void`.
116120
@js.JS('setCustomUserClaims')
117121
external js.JSPromise jsSetCustomUserClaims(
118-
String uid, js.JSAny? customUserClaims);
122+
String uid,
123+
js.JSAny? customUserClaims,
124+
);
119125

120126
/// Updates an existing user.
121127
///
122128
/// Returns a js.JSPromise containing updated [UserRecord].
123129
@js.JS('updateUser')
124130
external js.JSPromise<UserRecord> jsUpdateUser(
125-
String uid, UpdateUserRequest properties);
131+
String uid,
132+
UpdateUserRequest properties,
133+
);
126134

127135
/// Verifies a Firebase ID token (JWT).
128136
///
129137
/// If the token is valid, the returned js.JSPromise is fulfilled with an instance of
130138
/// [JSDecodedIdToken]; otherwise, the js.JSPromise is rejected. An optional flag can
131139
/// be passed to additionally check whether the ID token was revoked.
132140
@js.JS('jsVerifyIdToken')
133-
external js.JSPromise<JSDecodedIdToken> jsVerifyIdToken(String idToken,
134-
[bool? checkRevoked]);
141+
external js.JSPromise<JSDecodedIdToken> jsVerifyIdToken(
142+
String idToken, [
143+
bool? checkRevoked,
144+
]);
135145
}
136146

137147
extension type CreateUserRequest._(js.JSObject _) implements js.JSObject {
@@ -406,13 +416,14 @@ extension AuthExt2 on Auth {
406416
///
407417
/// Returns a [Future] containing a custom token string for the provided [uid]
408418
/// and payload.
409-
Future<String> createCustomToken(String uid,
410-
[Map<String, Object?>? developerClaims]) async =>
419+
Future<String> createCustomToken(
420+
String uid, [
421+
Map<String, Object?>? developerClaims,
422+
]) async =>
411423
(await jsCreateCustomToken(
412-
uid,
413-
(developerClaims ?? <String, Object?>{}).jsify()
414-
as js.JSObject)
415-
.toDart)
424+
uid,
425+
(developerClaims ?? <String, Object?>{}).jsify() as js.JSObject,
426+
).toDart)
416427
.toDart;
417428

418429
/// Creates a new user.
@@ -476,8 +487,9 @@ extension AuthExt2 on Auth {
476487
/// is transmitted on every authenticated request. For profile non-access
477488
/// related user attributes, use database or other separate storage systems.
478489
Future<void> setCustomUserClaims(
479-
String uid, Map<String, Object?> customUserClaims) =>
480-
jsSetCustomUserClaims(uid, customUserClaims.jsify()).toDart;
490+
String uid,
491+
Map<String, Object?> customUserClaims,
492+
) => jsSetCustomUserClaims(uid, customUserClaims.jsify()).toDart;
481493

482494
/// Updates an existing user.
483495
Future<UserRecord> updateUser(String uid, UpdateUserRequest properties) =>

auth_node/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version: 0.9.1
44
publish_to: none
55

66
environment:
7-
sdk: ^3.5.0
7+
sdk: ^3.7.0
88

99
dependencies:
1010
collection: ">=1.18.0"

auth_node/test/auth_node_test.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ Future<void> main() async {
2727

2828
group('auth_node', () {
2929
runAuthTests(
30-
firebase: firebase,
31-
authService: authService,
32-
options: context.appOptions);
30+
firebase: firebase,
31+
authService: authService,
32+
options: context.appOptions,
33+
);
3334
});
3435
}

firebase_node/lib/src/node/firebase_node.dart

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ FirebaseAdmin get firebaseNode =>
1818
extension FirebaseNodeAppOptionsExt on FirebaseAppOptions {
1919
/// Create a FirebaseAppOptions from a service account map
2020
FirebaseAppOptions withServiceAccountMap(
21-
Map<String, Object?> serviceAccountMap) {
22-
return FirebaseAppOptionsNode(serviceAccountMap,
23-
storageBucket: storageBucket);
21+
Map<String, Object?> serviceAccountMap,
22+
) {
23+
return FirebaseAppOptionsNode(
24+
serviceAccountMap,
25+
storageBucket: storageBucket,
26+
);
2427
}
2528
}
2629

@@ -45,7 +48,7 @@ class FirebaseAppOptionsNode
4548

4649
/// Constructor
4750
FirebaseAppOptionsNode(this.serviceAccountMap, {String? storageBucket})
48-
: _storageBucket = storageBucket;
51+
: _storageBucket = storageBucket;
4952

5053
/// The client email
5154
String get clientEmail {
@@ -69,7 +72,8 @@ class FirebaseAppOptionsNode
6972

7073
/// Create a FirebaseAppOptions from a service account map
7174
FirebaseAppOptions firebaseNodeAppOptionsFromServiceAccountMap(
72-
Map<String, Object?> serviceAccountMap) {
75+
Map<String, Object?> serviceAccountMap,
76+
) {
7377
return FirebaseAppOptionsNode(serviceAccountMap);
7478
}
7579

@@ -166,21 +170,27 @@ class FirebaseNode with FirebaseMixin implements FirebaseAdmin {
166170
FirebaseAdminCredentialServiceNode? _credentialService;
167171

168172
@override
169-
FirebaseAdminCredentialService get credential => _credentialService ??=
170-
FirebaseAdminCredentialServiceNode(native.firebaseAdminModule);
173+
FirebaseAdminCredentialService get credential =>
174+
_credentialService ??= FirebaseAdminCredentialServiceNode(
175+
native.firebaseAdminModule,
176+
);
171177
}
172178

173179
native.AppOptions? _unwrapAppOptions(
174-
FirebaseNode firebaseNode, FirebaseAppOptions? appOptions) {
180+
FirebaseNode firebaseNode,
181+
FirebaseAppOptions? appOptions,
182+
) {
175183
if (appOptions is FirebaseAppOptionsNode) {
176184
var projectId = appOptions.projectId;
177185
var storageBucket = appOptions.storageBucket;
178186
return native.AppOptions(
179187
credential: firebaseNode.nativeInstance.serviceAccountCredential(
180-
native.ServiceAccount(
181-
projectId: projectId,
182-
clientEmail: appOptions.clientEmail,
183-
privateKey: appOptions.privateKey)),
188+
native.ServiceAccount(
189+
projectId: projectId,
190+
clientEmail: appOptions.clientEmail,
191+
privateKey: appOptions.privateKey,
192+
),
193+
),
184194
//databaseURL: appOptions.databaseURL,
185195
projectId: projectId,
186196
storageBucket: storageBucket,
@@ -189,18 +199,20 @@ native.AppOptions? _unwrapAppOptions(
189199
}
190200
if (appOptions != null) {
191201
return native.AppOptions(
192-
databaseURL: appOptions.databaseURL,
193-
projectId: appOptions.projectId,
194-
storageBucket: appOptions.storageBucket);
202+
databaseURL: appOptions.databaseURL,
203+
projectId: appOptions.projectId,
204+
storageBucket: appOptions.storageBucket,
205+
);
195206
}
196207
return null;
197208
}
198209

199210
AppOptions _wrapAppOptions(native.AppOptions nativeInstance) {
200211
return AppOptions(
201-
databaseURL: nativeInstance.databaseURL,
202-
projectId: nativeInstance.projectId,
203-
storageBucket: nativeInstance.storageBucket);
212+
databaseURL: nativeInstance.databaseURL,
213+
projectId: nativeInstance.projectId,
214+
storageBucket: nativeInstance.storageBucket,
215+
);
204216
}
205217

206218
/// Compat

firebase_node/lib/src/node/firebase_node_js_interop.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import 'package:tekartik_core_node/require.dart' as node;
1111
const defaultAppName = '[DEFAULT]';
1212

1313
/// Singleton instance of [FirebaseAdminModule] module.
14-
final firebaseAdminModule =
15-
node.require<FirebaseAdminModule>('firebase-admin/app');
14+
final firebaseAdminModule = node.require<FirebaseAdminModule>(
15+
'firebase-admin/app',
16+
);
1617

1718
/// Firebase Admin SDK.
1819
extension type FirebaseAdminModule._(js.JSObject _) implements js.JSObject {}
@@ -84,12 +85,14 @@ extension CredentialsExt on Credentials {
8485
extension type ServiceAccount._(js.JSObject _) implements js.JSObject {
8586
/// Creates a new instance of [ServiceAccount].
8687
external factory ServiceAccount(
87-
// ignore: non_constant_identifier_names
88-
{String? projectId,
89-
// ignore: non_constant_identifier_names
90-
String? clientEmail,
91-
// ignore: non_constant_identifier_names
92-
String? privateKey});
88+
// ignore: non_constant_identifier_names
89+
{
90+
String? projectId,
91+
// ignore: non_constant_identifier_names
92+
String? clientEmail,
93+
// ignore: non_constant_identifier_names
94+
String? privateKey,
95+
});
9396
}
9497

9598
/// Service account.

firebase_node/lib/test/setup.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Future<FirebaseNodeTestContext> setup({
4040
var serviceAccountJsonOrPath = _envGetServiceAccountJsonOrPath();
4141
if (serviceAccountJsonOrPath == null) {
4242
throw UnsupportedError(
43-
'Missing env TEKARTIK_FIREBASE_NODE_TEST_SERVICE_ACCOUNT');
43+
'Missing env TEKARTIK_FIREBASE_NODE_TEST_SERVICE_ACCOUNT',
44+
);
4445
}
4546
Future<Map<String, Object?>> serviceAccountFromPath(String path) async {
4647
try {
@@ -90,8 +91,9 @@ bool get runningOnGithub => platform.runningOnGithub;
9091
/// ubuntu-latest
9192
bool isGithubActionsUbuntuAndDartStable() {
9293
return platform.environment['TEKARTIK_GITHUB_ACTIONS_DART'] == 'stable' &&
93-
(platform.environment['TEKARTIK_GITHUB_ACTIONS_OS']
94-
?.startsWith('ubuntu') ??
94+
(platform.environment['TEKARTIK_GITHUB_ACTIONS_OS']?.startsWith(
95+
'ubuntu',
96+
) ??
9597
false);
9698
}
9799

firebase_node/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ publish_to: none
66
#author: alex <email@example.com>
77

88
environment:
9-
sdk: ^3.5.0
9+
sdk: ^3.7.0
1010

1111
dependencies:
1212
collection: ">=1.18.0"
@@ -62,7 +62,7 @@ dev_dependencies:
6262
url: https://github.com/tekartik/firebase.dart
6363
path: firebase_test
6464
ref: dart3a
65-
version: '>=0.7.3'
65+
version: '>=0.7.3'
6666
process_run: ">=1.2.1+1"
6767
tekartik_app_node_build:
6868
git:

firebase_node/test/firebase_node_test.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ Future<void> main() async {
4040
var firebase = firebaseNode as FirebaseNode;
4141
// print(jsObjectKeys(firebase.nativeInstance));
4242
// [initializeApp, getApp, getApps, deleteApp, applicationDefault, cert, refreshToken, FirebaseAppError, AppErrorCodes, SDK_VERSION]
43-
var app = firebaseNode.initializeApp(
44-
options: context.appOptions, name: 'admin') as AppNode;
43+
var app =
44+
firebaseNode.initializeApp(options: context.appOptions, name: 'admin')
45+
as AppNode;
4546
// print(jsObjectKeys(app.nativeInstance!));
4647
// print(jsObjectGetOwnPropertyNames(app.nativeInstance!));
4748
// [appStore, services_, isDeleted_, name_, options_, INTERNAL]
4849
// print(firebase.credential.applicationDefault());
49-
print((await firebase.credential.applicationDefault()!.getAccessToken())
50-
.data);
50+
print(
51+
(await firebase.credential.applicationDefault()!.getAccessToken()).data,
52+
);
5153
print(app.options);
5254
print(app.options.projectId);
5355
await app.delete();

0 commit comments

Comments
 (0)