Skip to content

Commit a3f8f49

Browse files
committed
Add missing properties to Session object to reflect current state of gotrue-js
1 parent f40cf6f commit a3f8f49

File tree

1 file changed

+59
-36
lines changed

1 file changed

+59
-36
lines changed

Gotrue/Session.cs

Lines changed: 59 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,65 @@
11
using System;
22
using Newtonsoft.Json;
3+
34
#pragma warning disable CS1591
45

56
namespace Supabase.Gotrue
67
{
7-
/// <summary>
8-
/// Represents a Gotrue Session
9-
/// </summary>
10-
public class Session
11-
{
12-
[JsonProperty("access_token")]
13-
public string? AccessToken { get; set; }
14-
15-
[JsonProperty("expires_in")]
16-
public long ExpiresIn { get; set; }
17-
18-
[JsonProperty("refresh_token")]
19-
public string? RefreshToken { get; set; }
20-
21-
[JsonProperty("token_type")]
22-
public string? TokenType { get; set; }
23-
24-
[JsonProperty("user")]
25-
public User? User { get; set; }
26-
27-
[JsonProperty("created_at")]
28-
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
29-
30-
/// <summary>
31-
/// The expiration date of this session, in UTC time.
32-
/// </summary>
33-
/// <returns></returns>
34-
public DateTime ExpiresAt() => new DateTimeOffset(CreatedAt).AddSeconds(ExpiresIn).ToUniversalTime().DateTime;
35-
36-
/// <summary>
37-
/// Returns true if the session has expired
38-
/// </summary>
39-
/// <returns></returns>
40-
public bool Expired() => ExpiresAt() < DateTime.UtcNow;
41-
}
42-
}
8+
/// <summary>
9+
/// Represents a Gotrue Session
10+
/// </summary>
11+
public class Session
12+
{
13+
/// <summary>
14+
/// The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.
15+
/// </summary>
16+
[JsonProperty("access_token")]
17+
public string? AccessToken { get; set; }
18+
19+
/// <summary>
20+
/// The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.
21+
/// </summary>
22+
[JsonProperty("expires_in")]
23+
public long ExpiresIn { get; set; }
24+
25+
/// <summary>
26+
/// The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.
27+
/// </summary>
28+
[JsonProperty("provider_token")]
29+
public string? ProviderToken { get; set; }
30+
31+
/// <summary>
32+
/// The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API.
33+
/// Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.
34+
/// </summary>
35+
[JsonProperty("provider_refresh_token")]
36+
public string? ProviderRefreshToken { get; set; }
37+
38+
/// <summary>
39+
/// A one-time used refresh token that never expires.
40+
/// </summary>
41+
[JsonProperty("refresh_token")]
42+
public string? RefreshToken { get; set; }
43+
44+
[JsonProperty("token_type")]
45+
public string? TokenType { get; set; }
46+
47+
[JsonProperty("user")]
48+
public User? User { get; set; }
49+
50+
[JsonProperty("created_at")]
51+
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
52+
53+
/// <summary>
54+
/// The expiration date of this session, in UTC time.
55+
/// </summary>
56+
/// <returns></returns>
57+
public DateTime ExpiresAt() => new DateTimeOffset(CreatedAt).AddSeconds(ExpiresIn).ToUniversalTime().DateTime;
58+
59+
/// <summary>
60+
/// Returns true if the session has expired
61+
/// </summary>
62+
/// <returns></returns>
63+
public bool Expired() => ExpiresAt() < DateTime.UtcNow;
64+
}
65+
}

0 commit comments

Comments
 (0)