Skip to content

Commit b435ced

Browse files
committed
fix: redesign authorization resource targeting and default order handling
1 parent c90a5d6 commit b435ced

41 files changed

Lines changed: 589 additions & 224 deletions

Some content is hidden

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

.oagen-manifest.json

Lines changed: 84 additions & 1 deletion
Large diffs are not rendered by default.

lib/Resource/AssignRole.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
public function __construct(
1414
/** The slug of the role to assign. */
1515
public string $roleSlug,
16-
/** The ID of the resource. Use either this or `resource_external_id` and `resource_type_slug`. */
16+
/** The ID of the resource. Mutually exclusive with `resource_external_id` and `resource_type_slug`. */
1717
public ?string $resourceId = null,
18-
/** The external ID of the resource. Requires `resource_type_slug`. */
18+
/** The external ID of the resource. Required with `resource_type_slug`. Mutually exclusive with `resource_id`. */
1919
public ?string $resourceExternalId = null,
20-
/** The resource type slug. Required with `resource_external_id`. */
20+
/** The resource type slug. Required with `resource_external_id`. Mutually exclusive with `resource_id`. */
2121
public ?string $resourceTypeSlug = null,
2222
) {
2323
}

lib/Resource/AuthorizationCodeSessionAuthenticateRequest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public function __construct(
1818
public string $grantType,
1919
/** The authorization code received from the redirect. */
2020
public string $code,
21+
/** The PKCE code verifier used to derive the code challenge passed to the authorization URL. */
22+
public ?string $codeVerifier = null,
23+
/** An invitation token to accept during authentication. */
24+
public ?string $invitationToken = null,
2125
/** The IP address of the user's request. */
2226
public ?string $ipAddress = null,
2327
/** A unique identifier for the device. */
@@ -34,6 +38,8 @@ public static function fromArray(array $data): self
3438
clientSecret: $data['client_secret'],
3539
grantType: $data['grant_type'],
3640
code: $data['code'],
41+
codeVerifier: $data['code_verifier'] ?? null,
42+
invitationToken: $data['invitation_token'] ?? null,
3743
ipAddress: $data['ip_address'] ?? null,
3844
deviceId: $data['device_id'] ?? null,
3945
userAgent: $data['user_agent'] ?? null,
@@ -47,6 +53,8 @@ public function toArray(): array
4753
'client_secret' => $this->clientSecret,
4854
'grant_type' => $this->grantType,
4955
'code' => $this->code,
56+
'code_verifier' => $this->codeVerifier,
57+
'invitation_token' => $this->invitationToken,
5058
'ip_address' => $this->ipAddress,
5159
'device_id' => $this->deviceId,
5260
'user_agent' => $this->userAgent,

lib/Resource/AuthorizedConnectApplicationListData.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public function __construct(
2121
*/
2222
public array $grantedScopes,
2323
public ConnectApplication $application,
24+
/** The OAuth resource associated with the authorized connect application, if one was requested. */
25+
public ?string $oauthResource = null,
2426
) {
2527
}
2628

@@ -31,6 +33,7 @@ public static function fromArray(array $data): self
3133
id: $data['id'],
3234
grantedScopes: $data['granted_scopes'],
3335
application: ConnectApplication::fromArray($data['application']),
36+
oauthResource: $data['oauth_resource'] ?? null,
3437
);
3538
}
3639

@@ -41,6 +44,7 @@ public function toArray(): array
4144
'id' => $this->id,
4245
'granted_scopes' => $this->grantedScopes,
4346
'application' => $this->application->toArray(),
47+
'oauth_resource' => $this->oauthResource,
4448
];
4549
}
4650
}

lib/Resource/CheckAuthorization.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
public function __construct(
1414
/** The slug of the permission to check. */
1515
public string $permissionSlug,
16-
/** The ID of the resource. */
16+
/** The ID of the resource. Mutually exclusive with `resource_external_id` and `resource_type_slug`. */
1717
public ?string $resourceId = null,
18-
/** The external ID of the resource. */
18+
/** The external ID of the resource. Required with `resource_type_slug`. Mutually exclusive with `resource_id`. */
1919
public ?string $resourceExternalId = null,
20-
/** The slug of the resource type. */
20+
/** The slug of the resource type. Required with `resource_external_id`. Mutually exclusive with `resource_id`. */
2121
public ?string $resourceTypeSlug = null,
2222
) {
2323
}

lib/Resource/ConnectApplication.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public function __construct(
3030
public \DateTimeImmutable $createdAt,
3131
/** An ISO 8601 timestamp. */
3232
public \DateTimeImmutable $updatedAt,
33+
/** The type of the application. */
34+
public ?string $applicationType = null,
35+
/** The ID of the organization the application belongs to. */
36+
public ?string $organizationId = null,
3337
) {
3438
}
3539

@@ -44,6 +48,8 @@ public static function fromArray(array $data): self
4448
scopes: $data['scopes'],
4549
createdAt: new \DateTimeImmutable($data['created_at']),
4650
updatedAt: new \DateTimeImmutable($data['updated_at']),
51+
applicationType: $data['application_type'] ?? null,
52+
organizationId: $data['organization_id'] ?? null,
4753
);
4854
}
4955

@@ -58,6 +64,8 @@ public function toArray(): array
5864
'scopes' => $this->scopes,
5965
'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED),
6066
'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED),
67+
'application_type' => $this->applicationType,
68+
'organization_id' => $this->organizationId,
6169
];
6270
}
6371
}

lib/Resource/CreateAuthorizationResource.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public function __construct(
2121
public string $organizationId,
2222
/** An optional description of the resource. */
2323
public ?string $description = null,
24-
/** The ID of the parent resource. */
24+
/** The ID of the parent resource. Mutually exclusive with `parent_resource_external_id` and `parent_resource_type_slug`. */
2525
public ?string $parentResourceId = null,
26-
/** The external ID of the parent resource. */
26+
/** The external ID of the parent resource. Required with `parent_resource_type_slug`. Mutually exclusive with `parent_resource_id`. */
2727
public ?string $parentResourceExternalId = null,
28-
/** The resource type slug of the parent resource. */
28+
/** The resource type slug of the parent resource. Required with `parent_resource_external_id`. Mutually exclusive with `parent_resource_id`. */
2929
public ?string $parentResourceTypeSlug = null,
3030
) {
3131
}

lib/Resource/CreateUser.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
public function __construct(
1414
/** The email address of the user. */
1515
public string $email,
16-
/** The password to set for the user. Mutually exclusive with `password_hash` and `password_hash_type`. */
17-
public ?string $password = null,
18-
/** The hashed password to set for the user. Mutually exclusive with `password`. */
19-
public ?string $passwordHash = null,
20-
/** The algorithm originally used to hash the password, used when providing a `password_hash`. */
21-
public ?CreateUserPasswordHashType $passwordHashType = null,
2216
/** The first name of the user. */
2317
public ?string $firstName = null,
2418
/** The last name of the user. */
@@ -32,36 +26,42 @@ public function __construct(
3226
public ?array $metadata = null,
3327
/** The external ID of the user. */
3428
public ?string $externalId = null,
29+
/** The password to set for the user. Mutually exclusive with `password_hash` and `password_hash_type`. */
30+
public ?string $password = null,
31+
/** The hashed password to set for the user. Required with `password_hash_type`. Mutually exclusive with `password`. */
32+
public ?string $passwordHash = null,
33+
/** The algorithm originally used to hash the password, used when providing a `password_hash`. Required with `password_hash`. Mutually exclusive with `password`. */
34+
public ?CreateUserPasswordHashType $passwordHashType = null,
3535
) {
3636
}
3737

3838
public static function fromArray(array $data): self
3939
{
4040
return new self(
4141
email: $data['email'],
42-
password: $data['password'] ?? null,
43-
passwordHash: $data['password_hash'] ?? null,
44-
passwordHashType: isset($data['password_hash_type']) ? CreateUserPasswordHashType::from($data['password_hash_type']) : null,
4542
firstName: $data['first_name'] ?? null,
4643
lastName: $data['last_name'] ?? null,
4744
emailVerified: $data['email_verified'] ?? null,
4845
metadata: $data['metadata'] ?? null,
4946
externalId: $data['external_id'] ?? null,
47+
password: $data['password'] ?? null,
48+
passwordHash: $data['password_hash'] ?? null,
49+
passwordHashType: isset($data['password_hash_type']) ? CreateUserPasswordHashType::from($data['password_hash_type']) : null,
5050
);
5151
}
5252

5353
public function toArray(): array
5454
{
5555
return [
5656
'email' => $this->email,
57-
'password' => $this->password,
58-
'password_hash' => $this->passwordHash,
59-
'password_hash_type' => $this->passwordHashType?->value,
6057
'first_name' => $this->firstName,
6158
'last_name' => $this->lastName,
6259
'email_verified' => $this->emailVerified,
6360
'metadata' => $this->metadata,
6461
'external_id' => $this->externalId,
62+
'password' => $this->password,
63+
'password_hash' => $this->passwordHash,
64+
'password_hash_type' => $this->passwordHashType?->value,
6565
];
6666
}
6767
}

lib/Resource/CreateWebhookEndpointEvents.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ enum CreateWebhookEndpointEvents: string
4141
case DsyncUserDeleted = 'dsync.user.deleted';
4242
case DsyncUserUpdated = 'dsync.user.updated';
4343
case EmailVerificationCreated = 'email_verification.created';
44+
case GroupCreated = 'group.created';
45+
case GroupDeleted = 'group.deleted';
46+
case GroupMemberAdded = 'group.member_added';
47+
case GroupMemberRemoved = 'group.member_removed';
48+
case GroupUpdated = 'group.updated';
4449
case FlagCreated = 'flag.created';
4550
case FlagDeleted = 'flag.deleted';
4651
case FlagUpdated = 'flag.updated';

lib/Resource/DataIntegrationAccessTokenResponse.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,33 @@
1111
use JsonSerializableTrait;
1212

1313
public function __construct(
14+
/** Indicates whether the access token is valid and ready for use, or if reauthorization is required. */
15+
public ?bool $active = null,
16+
/** The [access token](https://workos.com/docs/reference/pipes/access-token) object, present when `active` is `true`. */
17+
public ?DataIntegrationAccessTokenResponseAccessToken $accessToken = null,
18+
/**
19+
* - `"not_installed"`: The user does not have the integration installed.
20+
* - `"needs_reauthorization"`: The user needs to reauthorize the integration.
21+
*/
22+
public ?DataIntegrationAccessTokenResponseError $error = null,
1423
) {
1524
}
1625

1726
public static function fromArray(array $data): self
1827
{
1928
return new self(
29+
active: $data['active'] ?? null,
30+
accessToken: isset($data['access_token']) ? DataIntegrationAccessTokenResponseAccessToken::fromArray($data['access_token']) : null,
31+
error: isset($data['error']) ? DataIntegrationAccessTokenResponseError::from($data['error']) : null,
2032
);
2133
}
2234

2335
public function toArray(): array
2436
{
2537
return [
38+
'active' => $this->active,
39+
'access_token' => $this->accessToken?->toArray(),
40+
'error' => $this->error?->value,
2641
];
2742
}
2843
}

0 commit comments

Comments
 (0)