Skip to content

Commit f8c0ae5

Browse files
committed
feat: exposing delegation
1 parent 8454854 commit f8c0ae5

File tree

13 files changed

+118
-8
lines changed

13 files changed

+118
-8
lines changed

apps/consent/app/graphql/generated.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,14 @@ export type CurrencyConversionEstimation = {
449449
readonly usdCentAmount: Scalars['CentAmount']['output'];
450450
};
451451

452+
export type Delegation = {
453+
readonly __typename: 'Delegation';
454+
readonly app: Scalars['String']['output'];
455+
readonly handledAt: Scalars['Timestamp']['output'];
456+
readonly remember: Scalars['Boolean']['output'];
457+
readonly scope: ReadonlyArray<Scalars['String']['output']>;
458+
};
459+
452460
export type DepositFeesInformation = {
453461
readonly __typename: 'DepositFeesInformation';
454462
readonly minBankFee: Scalars['String']['output'];
@@ -1921,6 +1929,8 @@ export type User = {
19211929
readonly contacts: ReadonlyArray<UserContact>;
19221930
readonly createdAt: Scalars['Timestamp']['output'];
19231931
readonly defaultAccount: Account;
1932+
/** List of Oauth2 delegations */
1933+
readonly delegations: ReadonlyArray<Delegation>;
19241934
/** Email address */
19251935
readonly email?: Maybe<Email>;
19261936
readonly id: Scalars['ID']['output'];

apps/dashboard/services/graphql/generated.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,14 @@ export type CurrencyConversionEstimation = {
489489
readonly usdCentAmount: Scalars['CentAmount']['output'];
490490
};
491491

492+
export type Delegation = {
493+
readonly __typename: 'Delegation';
494+
readonly app: Scalars['String']['output'];
495+
readonly handledAt: Scalars['Timestamp']['output'];
496+
readonly remember: Scalars['Boolean']['output'];
497+
readonly scope: ReadonlyArray<Scalars['String']['output']>;
498+
};
499+
492500
export type DepositFeesInformation = {
493501
readonly __typename: 'DepositFeesInformation';
494502
readonly minBankFee: Scalars['String']['output'];
@@ -2018,6 +2026,8 @@ export type User = {
20182026
readonly contacts: ReadonlyArray<UserContact>;
20192027
readonly createdAt: Scalars['Timestamp']['output'];
20202028
readonly defaultAccount: Account;
2029+
/** List of Oauth2 delegations */
2030+
readonly delegations: ReadonlyArray<Delegation>;
20212031
/** Email address */
20222032
readonly email?: Maybe<Email>;
20232033
readonly id: Scalars['ID']['output'];
@@ -3471,6 +3481,7 @@ export type ResolversTypes = {
34713481
CountryCode: ResolverTypeWrapper<Scalars['CountryCode']['output']>;
34723482
Currency: ResolverTypeWrapper<Currency>;
34733483
CurrencyConversionEstimation: ResolverTypeWrapper<CurrencyConversionEstimation>;
3484+
Delegation: ResolverTypeWrapper<Delegation>;
34743485
DepositFeesInformation: ResolverTypeWrapper<DepositFeesInformation>;
34753486
DeviceNotificationTokenCreateInput: DeviceNotificationTokenCreateInput;
34763487
DisplayCurrency: ResolverTypeWrapper<Scalars['DisplayCurrency']['output']>;
@@ -3699,6 +3710,7 @@ export type ResolversParentTypes = {
36993710
CountryCode: Scalars['CountryCode']['output'];
37003711
Currency: Currency;
37013712
CurrencyConversionEstimation: CurrencyConversionEstimation;
3713+
Delegation: Delegation;
37023714
DepositFeesInformation: DepositFeesInformation;
37033715
DeviceNotificationTokenCreateInput: DeviceNotificationTokenCreateInput;
37043716
DisplayCurrency: Scalars['DisplayCurrency']['output'];
@@ -4139,6 +4151,14 @@ export type CurrencyConversionEstimationResolvers<ContextType = any, ParentType
41394151
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
41404152
};
41414153

4154+
export type DelegationResolvers<ContextType = any, ParentType extends ResolversParentTypes['Delegation'] = ResolversParentTypes['Delegation']> = {
4155+
app?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
4156+
handledAt?: Resolver<ResolversTypes['Timestamp'], ParentType, ContextType>;
4157+
remember?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
4158+
scope?: Resolver<ReadonlyArray<ResolversTypes['String']>, ParentType, ContextType>;
4159+
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
4160+
};
4161+
41424162
export type DepositFeesInformationResolvers<ContextType = any, ParentType extends ResolversParentTypes['DepositFeesInformation'] = ResolversParentTypes['DepositFeesInformation']> = {
41434163
minBankFee?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
41444164
minBankFeeThreshold?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
@@ -4835,6 +4855,7 @@ export type UserResolvers<ContextType = any, ParentType extends ResolversParentT
48354855
contacts?: Resolver<ReadonlyArray<ResolversTypes['UserContact']>, ParentType, ContextType>;
48364856
createdAt?: Resolver<ResolversTypes['Timestamp'], ParentType, ContextType>;
48374857
defaultAccount?: Resolver<ResolversTypes['Account'], ParentType, ContextType>;
4858+
delegations?: Resolver<ReadonlyArray<ResolversTypes['Delegation']>, ParentType, ContextType>;
48384859
email?: Resolver<Maybe<ResolversTypes['Email']>, ParentType, ContextType>;
48394860
id?: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
48404861
language?: Resolver<ResolversTypes['Language'], ParentType, ContextType>;
@@ -4992,6 +5013,7 @@ export type Resolvers<ContextType = any> = {
49925013
CountryCode?: GraphQLScalarType;
49935014
Currency?: CurrencyResolvers<ContextType>;
49945015
CurrencyConversionEstimation?: CurrencyConversionEstimationResolvers<ContextType>;
5016+
Delegation?: DelegationResolvers<ContextType>;
49955017
DepositFeesInformation?: DepositFeesInformationResolvers<ContextType>;
49965018
DisplayCurrency?: GraphQLScalarType;
49975019
Email?: EmailResolvers<ContextType>;

apps/map/services/galoy/graphql/generated.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,14 @@ export type CurrencyConversionEstimation = {
449449
readonly usdCentAmount: Scalars['CentAmount']['output'];
450450
};
451451

452+
export type Delegation = {
453+
readonly __typename: 'Delegation';
454+
readonly app: Scalars['String']['output'];
455+
readonly handledAt: Scalars['Timestamp']['output'];
456+
readonly remember: Scalars['Boolean']['output'];
457+
readonly scope: ReadonlyArray<Scalars['String']['output']>;
458+
};
459+
452460
export type DepositFeesInformation = {
453461
readonly __typename: 'DepositFeesInformation';
454462
readonly minBankFee: Scalars['String']['output'];
@@ -1921,6 +1929,8 @@ export type User = {
19211929
readonly contacts: ReadonlyArray<UserContact>;
19221930
readonly createdAt: Scalars['Timestamp']['output'];
19231931
readonly defaultAccount: Account;
1932+
/** List of Oauth2 delegations */
1933+
readonly delegations: ReadonlyArray<Delegation>;
19241934
/** Email address */
19251935
readonly email?: Maybe<Email>;
19261936
readonly id: Scalars['ID']['output'];

apps/pay/lib/graphql/generated.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,14 @@ export type CurrencyConversionEstimation = {
448448
readonly usdCentAmount: Scalars['CentAmount'];
449449
};
450450

451+
export type Delegation = {
452+
readonly __typename: 'Delegation';
453+
readonly app: Scalars['String'];
454+
readonly handledAt: Scalars['Timestamp'];
455+
readonly remember: Scalars['Boolean'];
456+
readonly scope: ReadonlyArray<Scalars['String']>;
457+
};
458+
451459
export type DepositFeesInformation = {
452460
readonly __typename: 'DepositFeesInformation';
453461
readonly minBankFee: Scalars['String'];
@@ -1920,6 +1928,8 @@ export type User = {
19201928
readonly contacts: ReadonlyArray<UserContact>;
19211929
readonly createdAt: Scalars['Timestamp'];
19221930
readonly defaultAccount: Account;
1931+
/** List of Oauth2 delegations */
1932+
readonly delegations: ReadonlyArray<Delegation>;
19231933
/** Email address */
19241934
readonly email?: Maybe<Email>;
19251935
readonly id: Scalars['ID'];

bats/core/api/user.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ setup_file() {
2626
language="$(graphql_output '.data.me.language')"
2727
[[ "$language" == "$new_language" ]] || exit 1
2828
}
29+
30+
@test "user: list sessions" {
31+
exec_graphql 'alice' 'list-sessions'
32+
sessions="$(graphql_output '.data.me.mobileSessions')"
33+
id="$(echo "$sessions" | jq -r '.[0].id')" # Extracts the ID of the first element
34+
[[ "$sessions" != "[]" ]] && [[ -n "$id" ]] || exit 1
35+
}

bats/gql/list-sessions.gql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@ query userDetails {
77
expiresAt
88
issuedAt
99
}
10+
delegations {
11+
app
12+
handledAt
13+
remember
14+
scope
15+
}
1016
}
1117
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
import { consentList } from "@/services/hydra"
12
import { listSessions as listSessionsService } from "@/services/kratos"
23

34
export const listMobileSessions = async (userId: UserId) => {
4-
const list = await listSessionsService(userId)
5-
console.dir(list)
6-
return list
5+
return listSessionsService(userId)
76
}
87

9-
export const listDeleguateSessions = async (userId: UserId) => {
10-
8+
export const listDeleguations = async (userId: UserId) => {
9+
return consentList(userId)
1110
}

core/api/src/domain/authentication/index.types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type MobileSession = {
6868
issuedAt: Date
6969
}
7070

71-
type ConsentSession = {
71+
type Delegation = {
7272
scope: string[]
7373
handledAt: Date
7474
remember: boolean

core/api/src/graphql/public/schema.graphql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,13 @@ type CurrencyConversionEstimation {
354354
usdCentAmount: CentAmount!
355355
}
356356

357+
type Delegation {
358+
app: String!
359+
handledAt: Timestamp!
360+
remember: Boolean!
361+
scope: [String!]!
362+
}
363+
357364
type DepositFeesInformation {
358365
minBankFee: String!
359366

@@ -1595,6 +1602,9 @@ type User {
15951602
createdAt: Timestamp!
15961603
defaultAccount: Account!
15971604

1605+
"""List of Oauth2 delegations"""
1606+
delegations: [Delegation!]!
1607+
15981608
"""Email address"""
15991609
email: Email
16001610
id: ID!
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Timestamp from "@/graphql/shared/types/scalar/timestamp"
2+
3+
import { GT } from "@/graphql/index"
4+
5+
const Delegation = GT.Object({
6+
name: "Delegation",
7+
fields: () => ({
8+
app: { type: GT.NonNull(GT.String) },
9+
handledAt: { type: GT.NonNull(Timestamp) },
10+
remember: { type: GT.NonNull(GT.Boolean) },
11+
scope: { type: GT.NonNullList(GT.String) },
12+
}),
13+
})
14+
15+
export default Delegation

core/api/src/graphql/public/types/object/user.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Account from "../abstract/account"
44

55
import SupportMessage from "./support-message"
66
import AccountContact from "./account-contact"
7+
import Delegation from "./deleguation"
78

89
import { Accounts, Users, SupportChat } from "@/app"
910

@@ -84,6 +85,14 @@ const GraphQLUser = GT.Object<User, GraphQLPublicContextAuth>({
8485
},
8586
},
8687

88+
delegations: {
89+
type: GT.NonNullList(Delegation),
90+
description: "List of Oauth2 delegations",
91+
resolve: async (source, args, { user }) => {
92+
return Users.listDeleguations(user.id)
93+
},
94+
},
95+
8796
contacts: {
8897
deprecationReason: "will be moved to account",
8998
type: GT.NonNullList(AccountContact), // TODO: Make it a Connection Interface

core/api/src/services/hydra/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import axios, { AxiosResponse } from "axios"
22

33
const hydraUrl = process.env.HYDRA_ADMIN_URL || "http://localhost:4445"
44

5-
export const consentList = async (userId: UserId): Promise<ConsentSession[]> => {
5+
export const consentList = async (userId: UserId): Promise<Delegation[]> => {
66
let res: AxiosResponse<any, any>
77

88
try {
@@ -15,7 +15,7 @@ export const consentList = async (userId: UserId): Promise<ConsentSession[]> =>
1515
return []
1616
}
1717

18-
let sessions: ConsentSession[]
18+
let sessions: Delegation[]
1919

2020
try {
2121
/* eslint @typescript-eslint/ban-ts-comment: "off" */

dev/config/apollo-federation/supergraph.graphql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,15 @@ type CurrencyConversionEstimation
486486
usdCentAmount: CentAmount!
487487
}
488488

489+
type Delegation
490+
@join__type(graph: PUBLIC)
491+
{
492+
app: String!
493+
handledAt: Timestamp!
494+
remember: Boolean!
495+
scope: [String!]!
496+
}
497+
489498
type DepositFeesInformation
490499
@join__type(graph: PUBLIC)
491500
{
@@ -2085,6 +2094,9 @@ type User
20852094
createdAt: Timestamp! @join__field(graph: PUBLIC)
20862095
defaultAccount: Account! @join__field(graph: PUBLIC)
20872096

2097+
"""List of Oauth2 delegations"""
2098+
delegations: [Delegation!]! @join__field(graph: PUBLIC)
2099+
20882100
"""Email address"""
20892101
email: Email @join__field(graph: PUBLIC)
20902102

0 commit comments

Comments
 (0)