github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/identity/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package identity 5 6 import ( 7 "github.com/primecitizens/pcz/std/core/abi" 8 "github.com/primecitizens/pcz/std/core/mark" 9 "github.com/primecitizens/pcz/std/ffi/js" 10 "github.com/primecitizens/pcz/std/plat/js/webext/identity/bindings" 11 ) 12 13 type AccountInfo struct { 14 // Id is "AccountInfo.id" 15 // 16 // Optional 17 Id js.String 18 19 FFI_USE bool 20 } 21 22 // FromRef calls UpdateFrom and returns a AccountInfo with all fields set. 23 func (p AccountInfo) FromRef(ref js.Ref) AccountInfo { 24 p.UpdateFrom(ref) 25 return p 26 } 27 28 // New creates a new AccountInfo in the application heap. 29 func (p AccountInfo) New() js.Ref { 30 return bindings.AccountInfoJSLoad( 31 js.Pointer(&p), js.True, 0, 32 ) 33 } 34 35 // UpdateFrom copies value of all fields of the heap object to p. 36 func (p *AccountInfo) UpdateFrom(ref js.Ref) { 37 bindings.AccountInfoJSStore( 38 js.Pointer(p), ref, 39 ) 40 } 41 42 // Update writes all fields of the p to the heap object referenced by ref. 43 func (p *AccountInfo) Update(ref js.Ref) { 44 bindings.AccountInfoJSLoad( 45 js.Pointer(p), js.False, ref, 46 ) 47 } 48 49 // FreeMembers frees fields with heap reference, if recursive is true 50 // free all heap references reachable from p. 51 func (p *AccountInfo) FreeMembers(recursive bool) { 52 js.Free( 53 p.Id.Ref(), 54 ) 55 p.Id = p.Id.FromRef(js.Undefined) 56 } 57 58 type AccountStatus uint32 59 60 const ( 61 _ AccountStatus = iota 62 63 AccountStatus_SYNC 64 AccountStatus_ANY 65 ) 66 67 func (AccountStatus) FromRef(str js.Ref) AccountStatus { 68 return AccountStatus(bindings.ConstOfAccountStatus(str)) 69 } 70 71 func (x AccountStatus) String() (string, bool) { 72 switch x { 73 case AccountStatus_SYNC: 74 return "SYNC", true 75 case AccountStatus_ANY: 76 return "ANY", true 77 default: 78 return "", false 79 } 80 } 81 82 type ClearAllCachedAuthTokensCallbackFunc func(this js.Ref) js.Ref 83 84 func (fn ClearAllCachedAuthTokensCallbackFunc) Register() js.Func[func()] { 85 return js.RegisterCallback[func()]( 86 fn, abi.FuncPCABIInternal(fn), 87 ) 88 } 89 90 func (fn ClearAllCachedAuthTokensCallbackFunc) DispatchCallback( 91 targetPC uintptr, ctx *js.CallbackContext, 92 ) { 93 args := ctx.Args() 94 if len(args) != 0+1 /* js this */ || 95 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 96 js.ThrowInvalidCallbackInvocation() 97 } 98 99 if ctx.Return(fn( 100 args[0], 101 )) { 102 return 103 } 104 105 js.ThrowCallbackValueNotReturned() 106 } 107 108 type ClearAllCachedAuthTokensCallback[T any] struct { 109 Fn func(arg T, this js.Ref) js.Ref 110 Arg T 111 } 112 113 func (cb *ClearAllCachedAuthTokensCallback[T]) Register() js.Func[func()] { 114 return js.RegisterCallback[func()]( 115 cb, abi.FuncPCABIInternal(cb.Fn), 116 ) 117 } 118 119 func (cb *ClearAllCachedAuthTokensCallback[T]) DispatchCallback( 120 targetPC uintptr, ctx *js.CallbackContext, 121 ) { 122 args := ctx.Args() 123 if len(args) != 0+1 /* js this */ || 124 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 125 js.ThrowInvalidCallbackInvocation() 126 } 127 128 if ctx.Return(cb.Fn( 129 cb.Arg, 130 args[0], 131 )) { 132 return 133 } 134 135 js.ThrowCallbackValueNotReturned() 136 } 137 138 type GetAccountsCallbackFunc func(this js.Ref, accounts js.Array[AccountInfo]) js.Ref 139 140 func (fn GetAccountsCallbackFunc) Register() js.Func[func(accounts js.Array[AccountInfo])] { 141 return js.RegisterCallback[func(accounts js.Array[AccountInfo])]( 142 fn, abi.FuncPCABIInternal(fn), 143 ) 144 } 145 146 func (fn GetAccountsCallbackFunc) DispatchCallback( 147 targetPC uintptr, ctx *js.CallbackContext, 148 ) { 149 args := ctx.Args() 150 if len(args) != 1+1 /* js this */ || 151 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 152 js.ThrowInvalidCallbackInvocation() 153 } 154 155 if ctx.Return(fn( 156 args[0], 157 158 js.Array[AccountInfo]{}.FromRef(args[0+1]), 159 )) { 160 return 161 } 162 163 js.ThrowCallbackValueNotReturned() 164 } 165 166 type GetAccountsCallback[T any] struct { 167 Fn func(arg T, this js.Ref, accounts js.Array[AccountInfo]) js.Ref 168 Arg T 169 } 170 171 func (cb *GetAccountsCallback[T]) Register() js.Func[func(accounts js.Array[AccountInfo])] { 172 return js.RegisterCallback[func(accounts js.Array[AccountInfo])]( 173 cb, abi.FuncPCABIInternal(cb.Fn), 174 ) 175 } 176 177 func (cb *GetAccountsCallback[T]) DispatchCallback( 178 targetPC uintptr, ctx *js.CallbackContext, 179 ) { 180 args := ctx.Args() 181 if len(args) != 1+1 /* js this */ || 182 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 183 js.ThrowInvalidCallbackInvocation() 184 } 185 186 if ctx.Return(cb.Fn( 187 cb.Arg, 188 args[0], 189 190 js.Array[AccountInfo]{}.FromRef(args[0+1]), 191 )) { 192 return 193 } 194 195 js.ThrowCallbackValueNotReturned() 196 } 197 198 type GetAuthTokenCallbackFunc func(this js.Ref, result *GetAuthTokenResult) js.Ref 199 200 func (fn GetAuthTokenCallbackFunc) Register() js.Func[func(result *GetAuthTokenResult)] { 201 return js.RegisterCallback[func(result *GetAuthTokenResult)]( 202 fn, abi.FuncPCABIInternal(fn), 203 ) 204 } 205 206 func (fn GetAuthTokenCallbackFunc) DispatchCallback( 207 targetPC uintptr, ctx *js.CallbackContext, 208 ) { 209 args := ctx.Args() 210 if len(args) != 1+1 /* js this */ || 211 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 212 js.ThrowInvalidCallbackInvocation() 213 } 214 var arg0 GetAuthTokenResult 215 arg0.UpdateFrom(args[0+1]) 216 defer arg0.FreeMembers(true) 217 218 if ctx.Return(fn( 219 args[0], 220 221 mark.NoEscape(&arg0), 222 )) { 223 return 224 } 225 226 js.ThrowCallbackValueNotReturned() 227 } 228 229 type GetAuthTokenCallback[T any] struct { 230 Fn func(arg T, this js.Ref, result *GetAuthTokenResult) js.Ref 231 Arg T 232 } 233 234 func (cb *GetAuthTokenCallback[T]) Register() js.Func[func(result *GetAuthTokenResult)] { 235 return js.RegisterCallback[func(result *GetAuthTokenResult)]( 236 cb, abi.FuncPCABIInternal(cb.Fn), 237 ) 238 } 239 240 func (cb *GetAuthTokenCallback[T]) DispatchCallback( 241 targetPC uintptr, ctx *js.CallbackContext, 242 ) { 243 args := ctx.Args() 244 if len(args) != 1+1 /* js this */ || 245 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 246 js.ThrowInvalidCallbackInvocation() 247 } 248 var arg0 GetAuthTokenResult 249 arg0.UpdateFrom(args[0+1]) 250 defer arg0.FreeMembers(true) 251 252 if ctx.Return(cb.Fn( 253 cb.Arg, 254 args[0], 255 256 mark.NoEscape(&arg0), 257 )) { 258 return 259 } 260 261 js.ThrowCallbackValueNotReturned() 262 } 263 264 type GetAuthTokenResult struct { 265 // Token is "GetAuthTokenResult.token" 266 // 267 // Optional 268 Token js.String 269 // GrantedScopes is "GetAuthTokenResult.grantedScopes" 270 // 271 // Optional 272 GrantedScopes js.Array[js.String] 273 274 FFI_USE bool 275 } 276 277 // FromRef calls UpdateFrom and returns a GetAuthTokenResult with all fields set. 278 func (p GetAuthTokenResult) FromRef(ref js.Ref) GetAuthTokenResult { 279 p.UpdateFrom(ref) 280 return p 281 } 282 283 // New creates a new GetAuthTokenResult in the application heap. 284 func (p GetAuthTokenResult) New() js.Ref { 285 return bindings.GetAuthTokenResultJSLoad( 286 js.Pointer(&p), js.True, 0, 287 ) 288 } 289 290 // UpdateFrom copies value of all fields of the heap object to p. 291 func (p *GetAuthTokenResult) UpdateFrom(ref js.Ref) { 292 bindings.GetAuthTokenResultJSStore( 293 js.Pointer(p), ref, 294 ) 295 } 296 297 // Update writes all fields of the p to the heap object referenced by ref. 298 func (p *GetAuthTokenResult) Update(ref js.Ref) { 299 bindings.GetAuthTokenResultJSLoad( 300 js.Pointer(p), js.False, ref, 301 ) 302 } 303 304 // FreeMembers frees fields with heap reference, if recursive is true 305 // free all heap references reachable from p. 306 func (p *GetAuthTokenResult) FreeMembers(recursive bool) { 307 js.Free( 308 p.Token.Ref(), 309 p.GrantedScopes.Ref(), 310 ) 311 p.Token = p.Token.FromRef(js.Undefined) 312 p.GrantedScopes = p.GrantedScopes.FromRef(js.Undefined) 313 } 314 315 type GetProfileUserInfoCallbackFunc func(this js.Ref, userInfo *ProfileUserInfo) js.Ref 316 317 func (fn GetProfileUserInfoCallbackFunc) Register() js.Func[func(userInfo *ProfileUserInfo)] { 318 return js.RegisterCallback[func(userInfo *ProfileUserInfo)]( 319 fn, abi.FuncPCABIInternal(fn), 320 ) 321 } 322 323 func (fn GetProfileUserInfoCallbackFunc) DispatchCallback( 324 targetPC uintptr, ctx *js.CallbackContext, 325 ) { 326 args := ctx.Args() 327 if len(args) != 1+1 /* js this */ || 328 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 329 js.ThrowInvalidCallbackInvocation() 330 } 331 var arg0 ProfileUserInfo 332 arg0.UpdateFrom(args[0+1]) 333 defer arg0.FreeMembers(true) 334 335 if ctx.Return(fn( 336 args[0], 337 338 mark.NoEscape(&arg0), 339 )) { 340 return 341 } 342 343 js.ThrowCallbackValueNotReturned() 344 } 345 346 type GetProfileUserInfoCallback[T any] struct { 347 Fn func(arg T, this js.Ref, userInfo *ProfileUserInfo) js.Ref 348 Arg T 349 } 350 351 func (cb *GetProfileUserInfoCallback[T]) Register() js.Func[func(userInfo *ProfileUserInfo)] { 352 return js.RegisterCallback[func(userInfo *ProfileUserInfo)]( 353 cb, abi.FuncPCABIInternal(cb.Fn), 354 ) 355 } 356 357 func (cb *GetProfileUserInfoCallback[T]) DispatchCallback( 358 targetPC uintptr, ctx *js.CallbackContext, 359 ) { 360 args := ctx.Args() 361 if len(args) != 1+1 /* js this */ || 362 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 363 js.ThrowInvalidCallbackInvocation() 364 } 365 var arg0 ProfileUserInfo 366 arg0.UpdateFrom(args[0+1]) 367 defer arg0.FreeMembers(true) 368 369 if ctx.Return(cb.Fn( 370 cb.Arg, 371 args[0], 372 373 mark.NoEscape(&arg0), 374 )) { 375 return 376 } 377 378 js.ThrowCallbackValueNotReturned() 379 } 380 381 type ProfileUserInfo struct { 382 // Email is "ProfileUserInfo.email" 383 // 384 // Optional 385 Email js.String 386 // Id is "ProfileUserInfo.id" 387 // 388 // Optional 389 Id js.String 390 391 FFI_USE bool 392 } 393 394 // FromRef calls UpdateFrom and returns a ProfileUserInfo with all fields set. 395 func (p ProfileUserInfo) FromRef(ref js.Ref) ProfileUserInfo { 396 p.UpdateFrom(ref) 397 return p 398 } 399 400 // New creates a new ProfileUserInfo in the application heap. 401 func (p ProfileUserInfo) New() js.Ref { 402 return bindings.ProfileUserInfoJSLoad( 403 js.Pointer(&p), js.True, 0, 404 ) 405 } 406 407 // UpdateFrom copies value of all fields of the heap object to p. 408 func (p *ProfileUserInfo) UpdateFrom(ref js.Ref) { 409 bindings.ProfileUserInfoJSStore( 410 js.Pointer(p), ref, 411 ) 412 } 413 414 // Update writes all fields of the p to the heap object referenced by ref. 415 func (p *ProfileUserInfo) Update(ref js.Ref) { 416 bindings.ProfileUserInfoJSLoad( 417 js.Pointer(p), js.False, ref, 418 ) 419 } 420 421 // FreeMembers frees fields with heap reference, if recursive is true 422 // free all heap references reachable from p. 423 func (p *ProfileUserInfo) FreeMembers(recursive bool) { 424 js.Free( 425 p.Email.Ref(), 426 p.Id.Ref(), 427 ) 428 p.Email = p.Email.FromRef(js.Undefined) 429 p.Id = p.Id.FromRef(js.Undefined) 430 } 431 432 type InvalidTokenDetails struct { 433 // Token is "InvalidTokenDetails.token" 434 // 435 // Optional 436 Token js.String 437 438 FFI_USE bool 439 } 440 441 // FromRef calls UpdateFrom and returns a InvalidTokenDetails with all fields set. 442 func (p InvalidTokenDetails) FromRef(ref js.Ref) InvalidTokenDetails { 443 p.UpdateFrom(ref) 444 return p 445 } 446 447 // New creates a new InvalidTokenDetails in the application heap. 448 func (p InvalidTokenDetails) New() js.Ref { 449 return bindings.InvalidTokenDetailsJSLoad( 450 js.Pointer(&p), js.True, 0, 451 ) 452 } 453 454 // UpdateFrom copies value of all fields of the heap object to p. 455 func (p *InvalidTokenDetails) UpdateFrom(ref js.Ref) { 456 bindings.InvalidTokenDetailsJSStore( 457 js.Pointer(p), ref, 458 ) 459 } 460 461 // Update writes all fields of the p to the heap object referenced by ref. 462 func (p *InvalidTokenDetails) Update(ref js.Ref) { 463 bindings.InvalidTokenDetailsJSLoad( 464 js.Pointer(p), js.False, ref, 465 ) 466 } 467 468 // FreeMembers frees fields with heap reference, if recursive is true 469 // free all heap references reachable from p. 470 func (p *InvalidTokenDetails) FreeMembers(recursive bool) { 471 js.Free( 472 p.Token.Ref(), 473 ) 474 p.Token = p.Token.FromRef(js.Undefined) 475 } 476 477 type InvalidateAuthTokenCallbackFunc func(this js.Ref) js.Ref 478 479 func (fn InvalidateAuthTokenCallbackFunc) Register() js.Func[func()] { 480 return js.RegisterCallback[func()]( 481 fn, abi.FuncPCABIInternal(fn), 482 ) 483 } 484 485 func (fn InvalidateAuthTokenCallbackFunc) DispatchCallback( 486 targetPC uintptr, ctx *js.CallbackContext, 487 ) { 488 args := ctx.Args() 489 if len(args) != 0+1 /* js this */ || 490 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 491 js.ThrowInvalidCallbackInvocation() 492 } 493 494 if ctx.Return(fn( 495 args[0], 496 )) { 497 return 498 } 499 500 js.ThrowCallbackValueNotReturned() 501 } 502 503 type InvalidateAuthTokenCallback[T any] struct { 504 Fn func(arg T, this js.Ref) js.Ref 505 Arg T 506 } 507 508 func (cb *InvalidateAuthTokenCallback[T]) Register() js.Func[func()] { 509 return js.RegisterCallback[func()]( 510 cb, abi.FuncPCABIInternal(cb.Fn), 511 ) 512 } 513 514 func (cb *InvalidateAuthTokenCallback[T]) DispatchCallback( 515 targetPC uintptr, ctx *js.CallbackContext, 516 ) { 517 args := ctx.Args() 518 if len(args) != 0+1 /* js this */ || 519 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 520 js.ThrowInvalidCallbackInvocation() 521 } 522 523 if ctx.Return(cb.Fn( 524 cb.Arg, 525 args[0], 526 )) { 527 return 528 } 529 530 js.ThrowCallbackValueNotReturned() 531 } 532 533 type LaunchWebAuthFlowCallbackFunc func(this js.Ref, responseUrl js.String) js.Ref 534 535 func (fn LaunchWebAuthFlowCallbackFunc) Register() js.Func[func(responseUrl js.String)] { 536 return js.RegisterCallback[func(responseUrl js.String)]( 537 fn, abi.FuncPCABIInternal(fn), 538 ) 539 } 540 541 func (fn LaunchWebAuthFlowCallbackFunc) DispatchCallback( 542 targetPC uintptr, ctx *js.CallbackContext, 543 ) { 544 args := ctx.Args() 545 if len(args) != 1+1 /* js this */ || 546 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 547 js.ThrowInvalidCallbackInvocation() 548 } 549 550 if ctx.Return(fn( 551 args[0], 552 553 js.String{}.FromRef(args[0+1]), 554 )) { 555 return 556 } 557 558 js.ThrowCallbackValueNotReturned() 559 } 560 561 type LaunchWebAuthFlowCallback[T any] struct { 562 Fn func(arg T, this js.Ref, responseUrl js.String) js.Ref 563 Arg T 564 } 565 566 func (cb *LaunchWebAuthFlowCallback[T]) Register() js.Func[func(responseUrl js.String)] { 567 return js.RegisterCallback[func(responseUrl js.String)]( 568 cb, abi.FuncPCABIInternal(cb.Fn), 569 ) 570 } 571 572 func (cb *LaunchWebAuthFlowCallback[T]) DispatchCallback( 573 targetPC uintptr, ctx *js.CallbackContext, 574 ) { 575 args := ctx.Args() 576 if len(args) != 1+1 /* js this */ || 577 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 578 js.ThrowInvalidCallbackInvocation() 579 } 580 581 if ctx.Return(cb.Fn( 582 cb.Arg, 583 args[0], 584 585 js.String{}.FromRef(args[0+1]), 586 )) { 587 return 588 } 589 590 js.ThrowCallbackValueNotReturned() 591 } 592 593 type ProfileDetails struct { 594 // AccountStatus is "ProfileDetails.accountStatus" 595 // 596 // Optional 597 AccountStatus AccountStatus 598 599 FFI_USE bool 600 } 601 602 // FromRef calls UpdateFrom and returns a ProfileDetails with all fields set. 603 func (p ProfileDetails) FromRef(ref js.Ref) ProfileDetails { 604 p.UpdateFrom(ref) 605 return p 606 } 607 608 // New creates a new ProfileDetails in the application heap. 609 func (p ProfileDetails) New() js.Ref { 610 return bindings.ProfileDetailsJSLoad( 611 js.Pointer(&p), js.True, 0, 612 ) 613 } 614 615 // UpdateFrom copies value of all fields of the heap object to p. 616 func (p *ProfileDetails) UpdateFrom(ref js.Ref) { 617 bindings.ProfileDetailsJSStore( 618 js.Pointer(p), ref, 619 ) 620 } 621 622 // Update writes all fields of the p to the heap object referenced by ref. 623 func (p *ProfileDetails) Update(ref js.Ref) { 624 bindings.ProfileDetailsJSLoad( 625 js.Pointer(p), js.False, ref, 626 ) 627 } 628 629 // FreeMembers frees fields with heap reference, if recursive is true 630 // free all heap references reachable from p. 631 func (p *ProfileDetails) FreeMembers(recursive bool) { 632 } 633 634 type TokenDetails struct { 635 // Interactive is "TokenDetails.interactive" 636 // 637 // Optional 638 // 639 // NOTE: FFI_USE_Interactive MUST be set to true to make this field effective. 640 Interactive bool 641 // Account is "TokenDetails.account" 642 // 643 // Optional 644 // 645 // NOTE: Account.FFI_USE MUST be set to true to get Account used. 646 Account AccountInfo 647 // Scopes is "TokenDetails.scopes" 648 // 649 // Optional 650 Scopes js.Array[js.String] 651 // EnableGranularPermissions is "TokenDetails.enableGranularPermissions" 652 // 653 // Optional 654 // 655 // NOTE: FFI_USE_EnableGranularPermissions MUST be set to true to make this field effective. 656 EnableGranularPermissions bool 657 658 FFI_USE_Interactive bool // for Interactive. 659 FFI_USE_EnableGranularPermissions bool // for EnableGranularPermissions. 660 661 FFI_USE bool 662 } 663 664 // FromRef calls UpdateFrom and returns a TokenDetails with all fields set. 665 func (p TokenDetails) FromRef(ref js.Ref) TokenDetails { 666 p.UpdateFrom(ref) 667 return p 668 } 669 670 // New creates a new TokenDetails in the application heap. 671 func (p TokenDetails) New() js.Ref { 672 return bindings.TokenDetailsJSLoad( 673 js.Pointer(&p), js.True, 0, 674 ) 675 } 676 677 // UpdateFrom copies value of all fields of the heap object to p. 678 func (p *TokenDetails) UpdateFrom(ref js.Ref) { 679 bindings.TokenDetailsJSStore( 680 js.Pointer(p), ref, 681 ) 682 } 683 684 // Update writes all fields of the p to the heap object referenced by ref. 685 func (p *TokenDetails) Update(ref js.Ref) { 686 bindings.TokenDetailsJSLoad( 687 js.Pointer(p), js.False, ref, 688 ) 689 } 690 691 // FreeMembers frees fields with heap reference, if recursive is true 692 // free all heap references reachable from p. 693 func (p *TokenDetails) FreeMembers(recursive bool) { 694 js.Free( 695 p.Scopes.Ref(), 696 ) 697 p.Scopes = p.Scopes.FromRef(js.Undefined) 698 if recursive { 699 p.Account.FreeMembers(true) 700 } 701 } 702 703 type WebAuthFlowDetails struct { 704 // Url is "WebAuthFlowDetails.url" 705 // 706 // Optional 707 Url js.String 708 // Interactive is "WebAuthFlowDetails.interactive" 709 // 710 // Optional 711 // 712 // NOTE: FFI_USE_Interactive MUST be set to true to make this field effective. 713 Interactive bool 714 // AbortOnLoadForNonInteractive is "WebAuthFlowDetails.abortOnLoadForNonInteractive" 715 // 716 // Optional 717 // 718 // NOTE: FFI_USE_AbortOnLoadForNonInteractive MUST be set to true to make this field effective. 719 AbortOnLoadForNonInteractive bool 720 // TimeoutMsForNonInteractive is "WebAuthFlowDetails.timeoutMsForNonInteractive" 721 // 722 // Optional 723 // 724 // NOTE: FFI_USE_TimeoutMsForNonInteractive MUST be set to true to make this field effective. 725 TimeoutMsForNonInteractive int32 726 727 FFI_USE_Interactive bool // for Interactive. 728 FFI_USE_AbortOnLoadForNonInteractive bool // for AbortOnLoadForNonInteractive. 729 FFI_USE_TimeoutMsForNonInteractive bool // for TimeoutMsForNonInteractive. 730 731 FFI_USE bool 732 } 733 734 // FromRef calls UpdateFrom and returns a WebAuthFlowDetails with all fields set. 735 func (p WebAuthFlowDetails) FromRef(ref js.Ref) WebAuthFlowDetails { 736 p.UpdateFrom(ref) 737 return p 738 } 739 740 // New creates a new WebAuthFlowDetails in the application heap. 741 func (p WebAuthFlowDetails) New() js.Ref { 742 return bindings.WebAuthFlowDetailsJSLoad( 743 js.Pointer(&p), js.True, 0, 744 ) 745 } 746 747 // UpdateFrom copies value of all fields of the heap object to p. 748 func (p *WebAuthFlowDetails) UpdateFrom(ref js.Ref) { 749 bindings.WebAuthFlowDetailsJSStore( 750 js.Pointer(p), ref, 751 ) 752 } 753 754 // Update writes all fields of the p to the heap object referenced by ref. 755 func (p *WebAuthFlowDetails) Update(ref js.Ref) { 756 bindings.WebAuthFlowDetailsJSLoad( 757 js.Pointer(p), js.False, ref, 758 ) 759 } 760 761 // FreeMembers frees fields with heap reference, if recursive is true 762 // free all heap references reachable from p. 763 func (p *WebAuthFlowDetails) FreeMembers(recursive bool) { 764 js.Free( 765 p.Url.Ref(), 766 ) 767 p.Url = p.Url.FromRef(js.Undefined) 768 } 769 770 // HasFuncClearAllCachedAuthTokens returns true if the function "WEBEXT.identity.clearAllCachedAuthTokens" exists. 771 func HasFuncClearAllCachedAuthTokens() bool { 772 return js.True == bindings.HasFuncClearAllCachedAuthTokens() 773 } 774 775 // FuncClearAllCachedAuthTokens returns the function "WEBEXT.identity.clearAllCachedAuthTokens". 776 func FuncClearAllCachedAuthTokens() (fn js.Func[func() js.Promise[js.Void]]) { 777 bindings.FuncClearAllCachedAuthTokens( 778 js.Pointer(&fn), 779 ) 780 return 781 } 782 783 // ClearAllCachedAuthTokens calls the function "WEBEXT.identity.clearAllCachedAuthTokens" directly. 784 func ClearAllCachedAuthTokens() (ret js.Promise[js.Void]) { 785 bindings.CallClearAllCachedAuthTokens( 786 js.Pointer(&ret), 787 ) 788 789 return 790 } 791 792 // TryClearAllCachedAuthTokens calls the function "WEBEXT.identity.clearAllCachedAuthTokens" 793 // in a try/catch block and returns (_, err, ok = false) when it went through 794 // the catch clause. 795 func TryClearAllCachedAuthTokens() (ret js.Promise[js.Void], exception js.Any, ok bool) { 796 ok = js.True == bindings.TryClearAllCachedAuthTokens( 797 js.Pointer(&ret), js.Pointer(&exception), 798 ) 799 800 return 801 } 802 803 // HasFuncGetAccounts returns true if the function "WEBEXT.identity.getAccounts" exists. 804 func HasFuncGetAccounts() bool { 805 return js.True == bindings.HasFuncGetAccounts() 806 } 807 808 // FuncGetAccounts returns the function "WEBEXT.identity.getAccounts". 809 func FuncGetAccounts() (fn js.Func[func() js.Promise[js.Array[AccountInfo]]]) { 810 bindings.FuncGetAccounts( 811 js.Pointer(&fn), 812 ) 813 return 814 } 815 816 // GetAccounts calls the function "WEBEXT.identity.getAccounts" directly. 817 func GetAccounts() (ret js.Promise[js.Array[AccountInfo]]) { 818 bindings.CallGetAccounts( 819 js.Pointer(&ret), 820 ) 821 822 return 823 } 824 825 // TryGetAccounts calls the function "WEBEXT.identity.getAccounts" 826 // in a try/catch block and returns (_, err, ok = false) when it went through 827 // the catch clause. 828 func TryGetAccounts() (ret js.Promise[js.Array[AccountInfo]], exception js.Any, ok bool) { 829 ok = js.True == bindings.TryGetAccounts( 830 js.Pointer(&ret), js.Pointer(&exception), 831 ) 832 833 return 834 } 835 836 // HasFuncGetAuthToken returns true if the function "WEBEXT.identity.getAuthToken" exists. 837 func HasFuncGetAuthToken() bool { 838 return js.True == bindings.HasFuncGetAuthToken() 839 } 840 841 // FuncGetAuthToken returns the function "WEBEXT.identity.getAuthToken". 842 func FuncGetAuthToken() (fn js.Func[func(details TokenDetails) js.Promise[GetAuthTokenResult]]) { 843 bindings.FuncGetAuthToken( 844 js.Pointer(&fn), 845 ) 846 return 847 } 848 849 // GetAuthToken calls the function "WEBEXT.identity.getAuthToken" directly. 850 func GetAuthToken(details TokenDetails) (ret js.Promise[GetAuthTokenResult]) { 851 bindings.CallGetAuthToken( 852 js.Pointer(&ret), 853 js.Pointer(&details), 854 ) 855 856 return 857 } 858 859 // TryGetAuthToken calls the function "WEBEXT.identity.getAuthToken" 860 // in a try/catch block and returns (_, err, ok = false) when it went through 861 // the catch clause. 862 func TryGetAuthToken(details TokenDetails) (ret js.Promise[GetAuthTokenResult], exception js.Any, ok bool) { 863 ok = js.True == bindings.TryGetAuthToken( 864 js.Pointer(&ret), js.Pointer(&exception), 865 js.Pointer(&details), 866 ) 867 868 return 869 } 870 871 // HasFuncGetProfileUserInfo returns true if the function "WEBEXT.identity.getProfileUserInfo" exists. 872 func HasFuncGetProfileUserInfo() bool { 873 return js.True == bindings.HasFuncGetProfileUserInfo() 874 } 875 876 // FuncGetProfileUserInfo returns the function "WEBEXT.identity.getProfileUserInfo". 877 func FuncGetProfileUserInfo() (fn js.Func[func(details ProfileDetails) js.Promise[ProfileUserInfo]]) { 878 bindings.FuncGetProfileUserInfo( 879 js.Pointer(&fn), 880 ) 881 return 882 } 883 884 // GetProfileUserInfo calls the function "WEBEXT.identity.getProfileUserInfo" directly. 885 func GetProfileUserInfo(details ProfileDetails) (ret js.Promise[ProfileUserInfo]) { 886 bindings.CallGetProfileUserInfo( 887 js.Pointer(&ret), 888 js.Pointer(&details), 889 ) 890 891 return 892 } 893 894 // TryGetProfileUserInfo calls the function "WEBEXT.identity.getProfileUserInfo" 895 // in a try/catch block and returns (_, err, ok = false) when it went through 896 // the catch clause. 897 func TryGetProfileUserInfo(details ProfileDetails) (ret js.Promise[ProfileUserInfo], exception js.Any, ok bool) { 898 ok = js.True == bindings.TryGetProfileUserInfo( 899 js.Pointer(&ret), js.Pointer(&exception), 900 js.Pointer(&details), 901 ) 902 903 return 904 } 905 906 // HasFuncGetRedirectURL returns true if the function "WEBEXT.identity.getRedirectURL" exists. 907 func HasFuncGetRedirectURL() bool { 908 return js.True == bindings.HasFuncGetRedirectURL() 909 } 910 911 // FuncGetRedirectURL returns the function "WEBEXT.identity.getRedirectURL". 912 func FuncGetRedirectURL() (fn js.Func[func(path js.String) js.String]) { 913 bindings.FuncGetRedirectURL( 914 js.Pointer(&fn), 915 ) 916 return 917 } 918 919 // GetRedirectURL calls the function "WEBEXT.identity.getRedirectURL" directly. 920 func GetRedirectURL(path js.String) (ret js.String) { 921 bindings.CallGetRedirectURL( 922 js.Pointer(&ret), 923 path.Ref(), 924 ) 925 926 return 927 } 928 929 // TryGetRedirectURL calls the function "WEBEXT.identity.getRedirectURL" 930 // in a try/catch block and returns (_, err, ok = false) when it went through 931 // the catch clause. 932 func TryGetRedirectURL(path js.String) (ret js.String, exception js.Any, ok bool) { 933 ok = js.True == bindings.TryGetRedirectURL( 934 js.Pointer(&ret), js.Pointer(&exception), 935 path.Ref(), 936 ) 937 938 return 939 } 940 941 // HasFuncLaunchWebAuthFlow returns true if the function "WEBEXT.identity.launchWebAuthFlow" exists. 942 func HasFuncLaunchWebAuthFlow() bool { 943 return js.True == bindings.HasFuncLaunchWebAuthFlow() 944 } 945 946 // FuncLaunchWebAuthFlow returns the function "WEBEXT.identity.launchWebAuthFlow". 947 func FuncLaunchWebAuthFlow() (fn js.Func[func(details WebAuthFlowDetails) js.Promise[js.String]]) { 948 bindings.FuncLaunchWebAuthFlow( 949 js.Pointer(&fn), 950 ) 951 return 952 } 953 954 // LaunchWebAuthFlow calls the function "WEBEXT.identity.launchWebAuthFlow" directly. 955 func LaunchWebAuthFlow(details WebAuthFlowDetails) (ret js.Promise[js.String]) { 956 bindings.CallLaunchWebAuthFlow( 957 js.Pointer(&ret), 958 js.Pointer(&details), 959 ) 960 961 return 962 } 963 964 // TryLaunchWebAuthFlow calls the function "WEBEXT.identity.launchWebAuthFlow" 965 // in a try/catch block and returns (_, err, ok = false) when it went through 966 // the catch clause. 967 func TryLaunchWebAuthFlow(details WebAuthFlowDetails) (ret js.Promise[js.String], exception js.Any, ok bool) { 968 ok = js.True == bindings.TryLaunchWebAuthFlow( 969 js.Pointer(&ret), js.Pointer(&exception), 970 js.Pointer(&details), 971 ) 972 973 return 974 } 975 976 type OnSignInChangedEventCallbackFunc func(this js.Ref, account *AccountInfo, signedIn bool) js.Ref 977 978 func (fn OnSignInChangedEventCallbackFunc) Register() js.Func[func(account *AccountInfo, signedIn bool)] { 979 return js.RegisterCallback[func(account *AccountInfo, signedIn bool)]( 980 fn, abi.FuncPCABIInternal(fn), 981 ) 982 } 983 984 func (fn OnSignInChangedEventCallbackFunc) DispatchCallback( 985 targetPC uintptr, ctx *js.CallbackContext, 986 ) { 987 args := ctx.Args() 988 if len(args) != 2+1 /* js this */ || 989 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 990 js.ThrowInvalidCallbackInvocation() 991 } 992 var arg0 AccountInfo 993 arg0.UpdateFrom(args[0+1]) 994 defer arg0.FreeMembers(true) 995 996 if ctx.Return(fn( 997 args[0], 998 999 mark.NoEscape(&arg0), 1000 args[1+1] == js.True, 1001 )) { 1002 return 1003 } 1004 1005 js.ThrowCallbackValueNotReturned() 1006 } 1007 1008 type OnSignInChangedEventCallback[T any] struct { 1009 Fn func(arg T, this js.Ref, account *AccountInfo, signedIn bool) js.Ref 1010 Arg T 1011 } 1012 1013 func (cb *OnSignInChangedEventCallback[T]) Register() js.Func[func(account *AccountInfo, signedIn bool)] { 1014 return js.RegisterCallback[func(account *AccountInfo, signedIn bool)]( 1015 cb, abi.FuncPCABIInternal(cb.Fn), 1016 ) 1017 } 1018 1019 func (cb *OnSignInChangedEventCallback[T]) DispatchCallback( 1020 targetPC uintptr, ctx *js.CallbackContext, 1021 ) { 1022 args := ctx.Args() 1023 if len(args) != 2+1 /* js this */ || 1024 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1025 js.ThrowInvalidCallbackInvocation() 1026 } 1027 var arg0 AccountInfo 1028 arg0.UpdateFrom(args[0+1]) 1029 defer arg0.FreeMembers(true) 1030 1031 if ctx.Return(cb.Fn( 1032 cb.Arg, 1033 args[0], 1034 1035 mark.NoEscape(&arg0), 1036 args[1+1] == js.True, 1037 )) { 1038 return 1039 } 1040 1041 js.ThrowCallbackValueNotReturned() 1042 } 1043 1044 // HasFuncOnSignInChanged returns true if the function "WEBEXT.identity.onSignInChanged.addListener" exists. 1045 func HasFuncOnSignInChanged() bool { 1046 return js.True == bindings.HasFuncOnSignInChanged() 1047 } 1048 1049 // FuncOnSignInChanged returns the function "WEBEXT.identity.onSignInChanged.addListener". 1050 func FuncOnSignInChanged() (fn js.Func[func(callback js.Func[func(account *AccountInfo, signedIn bool)])]) { 1051 bindings.FuncOnSignInChanged( 1052 js.Pointer(&fn), 1053 ) 1054 return 1055 } 1056 1057 // OnSignInChanged calls the function "WEBEXT.identity.onSignInChanged.addListener" directly. 1058 func OnSignInChanged(callback js.Func[func(account *AccountInfo, signedIn bool)]) (ret js.Void) { 1059 bindings.CallOnSignInChanged( 1060 js.Pointer(&ret), 1061 callback.Ref(), 1062 ) 1063 1064 return 1065 } 1066 1067 // TryOnSignInChanged calls the function "WEBEXT.identity.onSignInChanged.addListener" 1068 // in a try/catch block and returns (_, err, ok = false) when it went through 1069 // the catch clause. 1070 func TryOnSignInChanged(callback js.Func[func(account *AccountInfo, signedIn bool)]) (ret js.Void, exception js.Any, ok bool) { 1071 ok = js.True == bindings.TryOnSignInChanged( 1072 js.Pointer(&ret), js.Pointer(&exception), 1073 callback.Ref(), 1074 ) 1075 1076 return 1077 } 1078 1079 // HasFuncOffSignInChanged returns true if the function "WEBEXT.identity.onSignInChanged.removeListener" exists. 1080 func HasFuncOffSignInChanged() bool { 1081 return js.True == bindings.HasFuncOffSignInChanged() 1082 } 1083 1084 // FuncOffSignInChanged returns the function "WEBEXT.identity.onSignInChanged.removeListener". 1085 func FuncOffSignInChanged() (fn js.Func[func(callback js.Func[func(account *AccountInfo, signedIn bool)])]) { 1086 bindings.FuncOffSignInChanged( 1087 js.Pointer(&fn), 1088 ) 1089 return 1090 } 1091 1092 // OffSignInChanged calls the function "WEBEXT.identity.onSignInChanged.removeListener" directly. 1093 func OffSignInChanged(callback js.Func[func(account *AccountInfo, signedIn bool)]) (ret js.Void) { 1094 bindings.CallOffSignInChanged( 1095 js.Pointer(&ret), 1096 callback.Ref(), 1097 ) 1098 1099 return 1100 } 1101 1102 // TryOffSignInChanged calls the function "WEBEXT.identity.onSignInChanged.removeListener" 1103 // in a try/catch block and returns (_, err, ok = false) when it went through 1104 // the catch clause. 1105 func TryOffSignInChanged(callback js.Func[func(account *AccountInfo, signedIn bool)]) (ret js.Void, exception js.Any, ok bool) { 1106 ok = js.True == bindings.TryOffSignInChanged( 1107 js.Pointer(&ret), js.Pointer(&exception), 1108 callback.Ref(), 1109 ) 1110 1111 return 1112 } 1113 1114 // HasFuncHasOnSignInChanged returns true if the function "WEBEXT.identity.onSignInChanged.hasListener" exists. 1115 func HasFuncHasOnSignInChanged() bool { 1116 return js.True == bindings.HasFuncHasOnSignInChanged() 1117 } 1118 1119 // FuncHasOnSignInChanged returns the function "WEBEXT.identity.onSignInChanged.hasListener". 1120 func FuncHasOnSignInChanged() (fn js.Func[func(callback js.Func[func(account *AccountInfo, signedIn bool)]) bool]) { 1121 bindings.FuncHasOnSignInChanged( 1122 js.Pointer(&fn), 1123 ) 1124 return 1125 } 1126 1127 // HasOnSignInChanged calls the function "WEBEXT.identity.onSignInChanged.hasListener" directly. 1128 func HasOnSignInChanged(callback js.Func[func(account *AccountInfo, signedIn bool)]) (ret bool) { 1129 bindings.CallHasOnSignInChanged( 1130 js.Pointer(&ret), 1131 callback.Ref(), 1132 ) 1133 1134 return 1135 } 1136 1137 // TryHasOnSignInChanged calls the function "WEBEXT.identity.onSignInChanged.hasListener" 1138 // in a try/catch block and returns (_, err, ok = false) when it went through 1139 // the catch clause. 1140 func TryHasOnSignInChanged(callback js.Func[func(account *AccountInfo, signedIn bool)]) (ret bool, exception js.Any, ok bool) { 1141 ok = js.True == bindings.TryHasOnSignInChanged( 1142 js.Pointer(&ret), js.Pointer(&exception), 1143 callback.Ref(), 1144 ) 1145 1146 return 1147 } 1148 1149 // HasFuncRemoveCachedAuthToken returns true if the function "WEBEXT.identity.removeCachedAuthToken" exists. 1150 func HasFuncRemoveCachedAuthToken() bool { 1151 return js.True == bindings.HasFuncRemoveCachedAuthToken() 1152 } 1153 1154 // FuncRemoveCachedAuthToken returns the function "WEBEXT.identity.removeCachedAuthToken". 1155 func FuncRemoveCachedAuthToken() (fn js.Func[func(details InvalidTokenDetails) js.Promise[js.Void]]) { 1156 bindings.FuncRemoveCachedAuthToken( 1157 js.Pointer(&fn), 1158 ) 1159 return 1160 } 1161 1162 // RemoveCachedAuthToken calls the function "WEBEXT.identity.removeCachedAuthToken" directly. 1163 func RemoveCachedAuthToken(details InvalidTokenDetails) (ret js.Promise[js.Void]) { 1164 bindings.CallRemoveCachedAuthToken( 1165 js.Pointer(&ret), 1166 js.Pointer(&details), 1167 ) 1168 1169 return 1170 } 1171 1172 // TryRemoveCachedAuthToken calls the function "WEBEXT.identity.removeCachedAuthToken" 1173 // in a try/catch block and returns (_, err, ok = false) when it went through 1174 // the catch clause. 1175 func TryRemoveCachedAuthToken(details InvalidTokenDetails) (ret js.Promise[js.Void], exception js.Any, ok bool) { 1176 ok = js.True == bindings.TryRemoveCachedAuthToken( 1177 js.Pointer(&ret), js.Pointer(&exception), 1178 js.Pointer(&details), 1179 ) 1180 1181 return 1182 }