perlsky is a Perl 5 implementation of an AT Protocol Personal Data Server.
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

Extend differential coverage for account invite codes

alice 1f8c68b5 232ab1a4

+62 -3
+1 -1
docs/ENDPOINT_CONFORMANCE.md
··· 14 14 The current differential harness directly compares: 15 15 16 16 - core account/session flows 17 - `describeServer`, `createAccount`, `createSession`, `getSession`, `refreshSession`, `deleteSession`, app-password lifecycle, password-boundary behavior, and email/account-delete flows 17 + `describeServer`, `createAccount`, `createSession`, `getSession`, `refreshSession`, `deleteSession`, `getAccountInviteCodes`, app-password lifecycle, password-boundary behavior, and email/account-delete flows 18 18 - identity flows 19 19 `resolveHandle`, `resolveDid`, `resolveIdentity`, PLC credential/signature/update flows, and handle-conflict semantics 20 20 - repo and sync flows
+61 -2
script/differential-validate
··· 2750 2750 check($invite_first->is_success, "$name first invite-code account creation succeeds"); 2751 2751 next unless $invite_first->is_success; 2752 2752 my $invite_first_did = ($invite_first->json || {})->{did}; 2753 + my $invite_first_access = ($invite_first->json || {})->{accessJwt}; 2753 2754 2754 2755 sleep 1.1; 2755 2756 ··· 2763 2764 next unless $invite_second->is_success; 2764 2765 my $invite_second_did = ($invite_second->json || {})->{did}; 2765 2766 2767 + my $account_batch = post_json( 2768 + $server{$name}{origin}, 2769 + 'com.atproto.server.createInviteCodes', 2770 + { 2771 + codeCount => 2, 2772 + useCount => 1, 2773 + forAccounts => [$invite_first_did], 2774 + }, 2775 + admin_auth_header($server{$name}{admin_password}), 2776 + ); 2777 + check($account_batch->is_success, "$name createInviteCodes succeeds for account-targeted batch"); 2778 + my @account_codes = @{ (($account_batch->json || {})->{codes} || [])->[0]{codes} || [] }; 2779 + 2780 + my $account_invites = get_json( 2781 + $server{$name}{origin}, 2782 + 'com.atproto.server.getAccountInviteCodes', 2783 + undef, 2784 + auth_header($invite_first_access), 2785 + ); 2786 + check($account_invites->is_success, "$name getAccountInviteCodes succeeds"); 2787 + 2766 2788 my $recent = get_form( 2767 2789 $server{$name}{origin}, 2768 2790 'com.atproto.admin.getInviteCodes', ··· 2789 2811 my %code_label = ( 2790 2812 ($used_code // q()) => 'used', 2791 2813 ($unused_code // q()) => 'unused', 2814 + ($account_codes[0] // q()) => 'account_first', 2815 + ($account_codes[1] // q()) => 'account_second', 2792 2816 ); 2793 2817 my %did_label = ( 2794 2818 ($invite_first_did // q()) => 'first', 2795 2819 ($invite_second_did // q()) => 'second', 2820 + ); 2821 + my %for_account_label = ( 2822 + admin => 'admin', 2823 + ($invite_first_did // q()) => 'first_account', 2824 + ); 2825 + my %account_code_label = ( 2826 + ($account_codes[0] // q()) => 'first', 2827 + ($account_codes[1] // q()) => 'second', 2796 2828 ); 2797 2829 my $normalize_codes = sub ($rows) { 2798 2830 return [ ··· 2801 2833 label => $code_label{$_->{code} // q()} // 'unknown', 2802 2834 available => $_->{available}, 2803 2835 disabled => $_->{disabled} ? 1 : 0, 2804 - forAccount => $_->{forAccount}, 2836 + forAccount => $for_account_label{$_->{forAccount} // q()} // 'unknown', 2805 2837 createdBy => $_->{createdBy}, 2806 2838 uses_count => scalar @{ $_->{uses} || [] }, 2807 2839 use_labels => [ map { $did_label{$_->{usedBy} // q()} // 'unknown' } @{ $_->{uses} || [] } ], ··· 2809 2841 } @$rows 2810 2842 ]; 2811 2843 }; 2844 + my $normalize_account_codes = sub ($rows) { 2845 + return [ sort { 2846 + ($a->{label} cmp $b->{label}) 2847 + || (($a->{forAccount} // q()) cmp ($b->{forAccount} // q())) 2848 + || (($a->{createdBy} // q()) cmp ($b->{createdBy} // q())) 2849 + } map { 2850 + +{ 2851 + label => $account_code_label{$_->{code} // q()} // 'unknown', 2852 + available => $_->{available}, 2853 + disabled => $_->{disabled} ? 1 : 0, 2854 + forAccount => $for_account_label{$_->{forAccount} // q()} // 'unknown', 2855 + createdBy => $_->{createdBy}, 2856 + uses_count => scalar @{ $_->{uses} || [] }, 2857 + } 2858 + } @$rows 2859 + ]; 2860 + }; 2812 2861 2813 2862 $server{$name}{admin_invite_code_listing} = { 2814 2863 disable_unused => { ··· 2821 2870 }, 2822 2871 usage => { 2823 2872 cursor_present => defined(($usage->json || {})->{cursor}) ? 1 : 0, 2824 - codes => $normalize_codes->(($usage->json || {})->{codes} || []), 2873 + codes => [ 2874 + sort { 2875 + ($b->{uses_count} <=> $a->{uses_count}) 2876 + || ($a->{disabled} <=> $b->{disabled}) 2877 + || (($a->{label} // q()) cmp ($b->{label} // q())) 2878 + || (($a->{forAccount} // q()) cmp ($b->{forAccount} // q())) 2879 + } @{ $normalize_codes->(($usage->json || {})->{codes} || []) } 2880 + ], 2881 + }, 2882 + account => { 2883 + codes => $normalize_account_codes->(($account_invites->json || {})->{codes} || []), 2825 2884 }, 2826 2885 bad_sort => normalize_xrpc_error($bad_sort), 2827 2886 };