github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/enterprise/platformkeys/apis_js_wasm.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  package platformkeys
     5  
     6  import (
     7  	"github.com/primecitizens/pcz/std/core/abi"
     8  	"github.com/primecitizens/pcz/std/ffi/js"
     9  	"github.com/primecitizens/pcz/std/plat/js/webext/enterprise/platformkeys/bindings"
    10  )
    11  
    12  type Algorithm uint32
    13  
    14  const (
    15  	_ Algorithm = iota
    16  
    17  	Algorithm_RSA
    18  	Algorithm_ECDSA
    19  )
    20  
    21  func (Algorithm) FromRef(str js.Ref) Algorithm {
    22  	return Algorithm(bindings.ConstOfAlgorithm(str))
    23  }
    24  
    25  func (x Algorithm) String() (string, bool) {
    26  	switch x {
    27  	case Algorithm_RSA:
    28  		return "RSA", true
    29  	case Algorithm_ECDSA:
    30  		return "ECDSA", true
    31  	default:
    32  		return "", false
    33  	}
    34  }
    35  
    36  type ChallengeCallbackFunc func(this js.Ref, response js.ArrayBuffer) js.Ref
    37  
    38  func (fn ChallengeCallbackFunc) Register() js.Func[func(response js.ArrayBuffer)] {
    39  	return js.RegisterCallback[func(response js.ArrayBuffer)](
    40  		fn, abi.FuncPCABIInternal(fn),
    41  	)
    42  }
    43  
    44  func (fn ChallengeCallbackFunc) DispatchCallback(
    45  	targetPC uintptr, ctx *js.CallbackContext,
    46  ) {
    47  	args := ctx.Args()
    48  	if len(args) != 1+1 /* js this */ ||
    49  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
    50  		js.ThrowInvalidCallbackInvocation()
    51  	}
    52  
    53  	if ctx.Return(fn(
    54  		args[0],
    55  
    56  		js.ArrayBuffer{}.FromRef(args[0+1]),
    57  	)) {
    58  		return
    59  	}
    60  
    61  	js.ThrowCallbackValueNotReturned()
    62  }
    63  
    64  type ChallengeCallback[T any] struct {
    65  	Fn  func(arg T, this js.Ref, response js.ArrayBuffer) js.Ref
    66  	Arg T
    67  }
    68  
    69  func (cb *ChallengeCallback[T]) Register() js.Func[func(response js.ArrayBuffer)] {
    70  	return js.RegisterCallback[func(response js.ArrayBuffer)](
    71  		cb, abi.FuncPCABIInternal(cb.Fn),
    72  	)
    73  }
    74  
    75  func (cb *ChallengeCallback[T]) DispatchCallback(
    76  	targetPC uintptr, ctx *js.CallbackContext,
    77  ) {
    78  	args := ctx.Args()
    79  	if len(args) != 1+1 /* js this */ ||
    80  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
    81  		js.ThrowInvalidCallbackInvocation()
    82  	}
    83  
    84  	if ctx.Return(cb.Fn(
    85  		cb.Arg,
    86  		args[0],
    87  
    88  		js.ArrayBuffer{}.FromRef(args[0+1]),
    89  	)) {
    90  		return
    91  	}
    92  
    93  	js.ThrowCallbackValueNotReturned()
    94  }
    95  
    96  type RegisterKeyOptions struct {
    97  	// Algorithm is "RegisterKeyOptions.algorithm"
    98  	//
    99  	// Optional
   100  	Algorithm Algorithm
   101  
   102  	FFI_USE bool
   103  }
   104  
   105  // FromRef calls UpdateFrom and returns a RegisterKeyOptions with all fields set.
   106  func (p RegisterKeyOptions) FromRef(ref js.Ref) RegisterKeyOptions {
   107  	p.UpdateFrom(ref)
   108  	return p
   109  }
   110  
   111  // New creates a new RegisterKeyOptions in the application heap.
   112  func (p RegisterKeyOptions) New() js.Ref {
   113  	return bindings.RegisterKeyOptionsJSLoad(
   114  		js.Pointer(&p), js.True, 0,
   115  	)
   116  }
   117  
   118  // UpdateFrom copies value of all fields of the heap object to p.
   119  func (p *RegisterKeyOptions) UpdateFrom(ref js.Ref) {
   120  	bindings.RegisterKeyOptionsJSStore(
   121  		js.Pointer(p), ref,
   122  	)
   123  }
   124  
   125  // Update writes all fields of the p to the heap object referenced by ref.
   126  func (p *RegisterKeyOptions) Update(ref js.Ref) {
   127  	bindings.RegisterKeyOptionsJSLoad(
   128  		js.Pointer(p), js.False, ref,
   129  	)
   130  }
   131  
   132  // FreeMembers frees fields with heap reference, if recursive is true
   133  // free all heap references reachable from p.
   134  func (p *RegisterKeyOptions) FreeMembers(recursive bool) {
   135  }
   136  
   137  type Scope uint32
   138  
   139  const (
   140  	_ Scope = iota
   141  
   142  	Scope_USER
   143  	Scope_MACHINE
   144  )
   145  
   146  func (Scope) FromRef(str js.Ref) Scope {
   147  	return Scope(bindings.ConstOfScope(str))
   148  }
   149  
   150  func (x Scope) String() (string, bool) {
   151  	switch x {
   152  	case Scope_USER:
   153  		return "USER", true
   154  	case Scope_MACHINE:
   155  		return "MACHINE", true
   156  	default:
   157  		return "", false
   158  	}
   159  }
   160  
   161  type ChallengeKeyOptions struct {
   162  	// Challenge is "ChallengeKeyOptions.challenge"
   163  	//
   164  	// Optional
   165  	Challenge js.ArrayBuffer
   166  	// RegisterKey is "ChallengeKeyOptions.registerKey"
   167  	//
   168  	// Optional
   169  	//
   170  	// NOTE: RegisterKey.FFI_USE MUST be set to true to get RegisterKey used.
   171  	RegisterKey RegisterKeyOptions
   172  	// Scope is "ChallengeKeyOptions.scope"
   173  	//
   174  	// Optional
   175  	Scope Scope
   176  
   177  	FFI_USE bool
   178  }
   179  
   180  // FromRef calls UpdateFrom and returns a ChallengeKeyOptions with all fields set.
   181  func (p ChallengeKeyOptions) FromRef(ref js.Ref) ChallengeKeyOptions {
   182  	p.UpdateFrom(ref)
   183  	return p
   184  }
   185  
   186  // New creates a new ChallengeKeyOptions in the application heap.
   187  func (p ChallengeKeyOptions) New() js.Ref {
   188  	return bindings.ChallengeKeyOptionsJSLoad(
   189  		js.Pointer(&p), js.True, 0,
   190  	)
   191  }
   192  
   193  // UpdateFrom copies value of all fields of the heap object to p.
   194  func (p *ChallengeKeyOptions) UpdateFrom(ref js.Ref) {
   195  	bindings.ChallengeKeyOptionsJSStore(
   196  		js.Pointer(p), ref,
   197  	)
   198  }
   199  
   200  // Update writes all fields of the p to the heap object referenced by ref.
   201  func (p *ChallengeKeyOptions) Update(ref js.Ref) {
   202  	bindings.ChallengeKeyOptionsJSLoad(
   203  		js.Pointer(p), js.False, ref,
   204  	)
   205  }
   206  
   207  // FreeMembers frees fields with heap reference, if recursive is true
   208  // free all heap references reachable from p.
   209  func (p *ChallengeKeyOptions) FreeMembers(recursive bool) {
   210  	js.Free(
   211  		p.Challenge.Ref(),
   212  	)
   213  	p.Challenge = p.Challenge.FromRef(js.Undefined)
   214  	if recursive {
   215  		p.RegisterKey.FreeMembers(true)
   216  	}
   217  }
   218  
   219  type DoneCallbackFunc func(this js.Ref) js.Ref
   220  
   221  func (fn DoneCallbackFunc) Register() js.Func[func()] {
   222  	return js.RegisterCallback[func()](
   223  		fn, abi.FuncPCABIInternal(fn),
   224  	)
   225  }
   226  
   227  func (fn DoneCallbackFunc) DispatchCallback(
   228  	targetPC uintptr, ctx *js.CallbackContext,
   229  ) {
   230  	args := ctx.Args()
   231  	if len(args) != 0+1 /* js this */ ||
   232  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   233  		js.ThrowInvalidCallbackInvocation()
   234  	}
   235  
   236  	if ctx.Return(fn(
   237  		args[0],
   238  	)) {
   239  		return
   240  	}
   241  
   242  	js.ThrowCallbackValueNotReturned()
   243  }
   244  
   245  type DoneCallback[T any] struct {
   246  	Fn  func(arg T, this js.Ref) js.Ref
   247  	Arg T
   248  }
   249  
   250  func (cb *DoneCallback[T]) Register() js.Func[func()] {
   251  	return js.RegisterCallback[func()](
   252  		cb, abi.FuncPCABIInternal(cb.Fn),
   253  	)
   254  }
   255  
   256  func (cb *DoneCallback[T]) DispatchCallback(
   257  	targetPC uintptr, ctx *js.CallbackContext,
   258  ) {
   259  	args := ctx.Args()
   260  	if len(args) != 0+1 /* js this */ ||
   261  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   262  		js.ThrowInvalidCallbackInvocation()
   263  	}
   264  
   265  	if ctx.Return(cb.Fn(
   266  		cb.Arg,
   267  		args[0],
   268  	)) {
   269  		return
   270  	}
   271  
   272  	js.ThrowCallbackValueNotReturned()
   273  }
   274  
   275  type GetCertificatesCallbackFunc func(this js.Ref, certificates js.Array[js.ArrayBuffer]) js.Ref
   276  
   277  func (fn GetCertificatesCallbackFunc) Register() js.Func[func(certificates js.Array[js.ArrayBuffer])] {
   278  	return js.RegisterCallback[func(certificates js.Array[js.ArrayBuffer])](
   279  		fn, abi.FuncPCABIInternal(fn),
   280  	)
   281  }
   282  
   283  func (fn GetCertificatesCallbackFunc) DispatchCallback(
   284  	targetPC uintptr, ctx *js.CallbackContext,
   285  ) {
   286  	args := ctx.Args()
   287  	if len(args) != 1+1 /* js this */ ||
   288  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   289  		js.ThrowInvalidCallbackInvocation()
   290  	}
   291  
   292  	if ctx.Return(fn(
   293  		args[0],
   294  
   295  		js.Array[js.ArrayBuffer]{}.FromRef(args[0+1]),
   296  	)) {
   297  		return
   298  	}
   299  
   300  	js.ThrowCallbackValueNotReturned()
   301  }
   302  
   303  type GetCertificatesCallback[T any] struct {
   304  	Fn  func(arg T, this js.Ref, certificates js.Array[js.ArrayBuffer]) js.Ref
   305  	Arg T
   306  }
   307  
   308  func (cb *GetCertificatesCallback[T]) Register() js.Func[func(certificates js.Array[js.ArrayBuffer])] {
   309  	return js.RegisterCallback[func(certificates js.Array[js.ArrayBuffer])](
   310  		cb, abi.FuncPCABIInternal(cb.Fn),
   311  	)
   312  }
   313  
   314  func (cb *GetCertificatesCallback[T]) DispatchCallback(
   315  	targetPC uintptr, ctx *js.CallbackContext,
   316  ) {
   317  	args := ctx.Args()
   318  	if len(args) != 1+1 /* js this */ ||
   319  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   320  		js.ThrowInvalidCallbackInvocation()
   321  	}
   322  
   323  	if ctx.Return(cb.Fn(
   324  		cb.Arg,
   325  		args[0],
   326  
   327  		js.Array[js.ArrayBuffer]{}.FromRef(args[0+1]),
   328  	)) {
   329  		return
   330  	}
   331  
   332  	js.ThrowCallbackValueNotReturned()
   333  }
   334  
   335  type GetTokensCallbackFunc func(this js.Ref, tokens js.Array[Token]) js.Ref
   336  
   337  func (fn GetTokensCallbackFunc) Register() js.Func[func(tokens js.Array[Token])] {
   338  	return js.RegisterCallback[func(tokens js.Array[Token])](
   339  		fn, abi.FuncPCABIInternal(fn),
   340  	)
   341  }
   342  
   343  func (fn GetTokensCallbackFunc) DispatchCallback(
   344  	targetPC uintptr, ctx *js.CallbackContext,
   345  ) {
   346  	args := ctx.Args()
   347  	if len(args) != 1+1 /* js this */ ||
   348  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   349  		js.ThrowInvalidCallbackInvocation()
   350  	}
   351  
   352  	if ctx.Return(fn(
   353  		args[0],
   354  
   355  		js.Array[Token]{}.FromRef(args[0+1]),
   356  	)) {
   357  		return
   358  	}
   359  
   360  	js.ThrowCallbackValueNotReturned()
   361  }
   362  
   363  type GetTokensCallback[T any] struct {
   364  	Fn  func(arg T, this js.Ref, tokens js.Array[Token]) js.Ref
   365  	Arg T
   366  }
   367  
   368  func (cb *GetTokensCallback[T]) Register() js.Func[func(tokens js.Array[Token])] {
   369  	return js.RegisterCallback[func(tokens js.Array[Token])](
   370  		cb, abi.FuncPCABIInternal(cb.Fn),
   371  	)
   372  }
   373  
   374  func (cb *GetTokensCallback[T]) DispatchCallback(
   375  	targetPC uintptr, ctx *js.CallbackContext,
   376  ) {
   377  	args := ctx.Args()
   378  	if len(args) != 1+1 /* js this */ ||
   379  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   380  		js.ThrowInvalidCallbackInvocation()
   381  	}
   382  
   383  	if ctx.Return(cb.Fn(
   384  		cb.Arg,
   385  		args[0],
   386  
   387  		js.Array[Token]{}.FromRef(args[0+1]),
   388  	)) {
   389  		return
   390  	}
   391  
   392  	js.ThrowCallbackValueNotReturned()
   393  }
   394  
   395  type Token struct {
   396  	// Id is "Token.id"
   397  	//
   398  	// Optional
   399  	Id js.String
   400  	// SubtleCrypto is "Token.subtleCrypto"
   401  	//
   402  	// Optional
   403  	SubtleCrypto js.Object
   404  	// SoftwareBackedSubtleCrypto is "Token.softwareBackedSubtleCrypto"
   405  	//
   406  	// Optional
   407  	SoftwareBackedSubtleCrypto js.Object
   408  
   409  	FFI_USE bool
   410  }
   411  
   412  // FromRef calls UpdateFrom and returns a Token with all fields set.
   413  func (p Token) FromRef(ref js.Ref) Token {
   414  	p.UpdateFrom(ref)
   415  	return p
   416  }
   417  
   418  // New creates a new Token in the application heap.
   419  func (p Token) New() js.Ref {
   420  	return bindings.TokenJSLoad(
   421  		js.Pointer(&p), js.True, 0,
   422  	)
   423  }
   424  
   425  // UpdateFrom copies value of all fields of the heap object to p.
   426  func (p *Token) UpdateFrom(ref js.Ref) {
   427  	bindings.TokenJSStore(
   428  		js.Pointer(p), ref,
   429  	)
   430  }
   431  
   432  // Update writes all fields of the p to the heap object referenced by ref.
   433  func (p *Token) Update(ref js.Ref) {
   434  	bindings.TokenJSLoad(
   435  		js.Pointer(p), js.False, ref,
   436  	)
   437  }
   438  
   439  // FreeMembers frees fields with heap reference, if recursive is true
   440  // free all heap references reachable from p.
   441  func (p *Token) FreeMembers(recursive bool) {
   442  	js.Free(
   443  		p.Id.Ref(),
   444  		p.SubtleCrypto.Ref(),
   445  		p.SoftwareBackedSubtleCrypto.Ref(),
   446  	)
   447  	p.Id = p.Id.FromRef(js.Undefined)
   448  	p.SubtleCrypto = p.SubtleCrypto.FromRef(js.Undefined)
   449  	p.SoftwareBackedSubtleCrypto = p.SoftwareBackedSubtleCrypto.FromRef(js.Undefined)
   450  }
   451  
   452  // HasFuncChallengeKey returns true if the function "WEBEXT.enterprise.platformKeys.challengeKey" exists.
   453  func HasFuncChallengeKey() bool {
   454  	return js.True == bindings.HasFuncChallengeKey()
   455  }
   456  
   457  // FuncChallengeKey returns the function "WEBEXT.enterprise.platformKeys.challengeKey".
   458  func FuncChallengeKey() (fn js.Func[func(options ChallengeKeyOptions, callback js.Func[func(response js.ArrayBuffer)])]) {
   459  	bindings.FuncChallengeKey(
   460  		js.Pointer(&fn),
   461  	)
   462  	return
   463  }
   464  
   465  // ChallengeKey calls the function "WEBEXT.enterprise.platformKeys.challengeKey" directly.
   466  func ChallengeKey(options ChallengeKeyOptions, callback js.Func[func(response js.ArrayBuffer)]) (ret js.Void) {
   467  	bindings.CallChallengeKey(
   468  		js.Pointer(&ret),
   469  		js.Pointer(&options),
   470  		callback.Ref(),
   471  	)
   472  
   473  	return
   474  }
   475  
   476  // TryChallengeKey calls the function "WEBEXT.enterprise.platformKeys.challengeKey"
   477  // in a try/catch block and returns (_, err, ok = false) when it went through
   478  // the catch clause.
   479  func TryChallengeKey(options ChallengeKeyOptions, callback js.Func[func(response js.ArrayBuffer)]) (ret js.Void, exception js.Any, ok bool) {
   480  	ok = js.True == bindings.TryChallengeKey(
   481  		js.Pointer(&ret), js.Pointer(&exception),
   482  		js.Pointer(&options),
   483  		callback.Ref(),
   484  	)
   485  
   486  	return
   487  }
   488  
   489  // HasFuncChallengeMachineKey returns true if the function "WEBEXT.enterprise.platformKeys.challengeMachineKey" exists.
   490  func HasFuncChallengeMachineKey() bool {
   491  	return js.True == bindings.HasFuncChallengeMachineKey()
   492  }
   493  
   494  // FuncChallengeMachineKey returns the function "WEBEXT.enterprise.platformKeys.challengeMachineKey".
   495  func FuncChallengeMachineKey() (fn js.Func[func(challenge js.ArrayBuffer, registerKey bool, callback js.Func[func(response js.ArrayBuffer)])]) {
   496  	bindings.FuncChallengeMachineKey(
   497  		js.Pointer(&fn),
   498  	)
   499  	return
   500  }
   501  
   502  // ChallengeMachineKey calls the function "WEBEXT.enterprise.platformKeys.challengeMachineKey" directly.
   503  func ChallengeMachineKey(challenge js.ArrayBuffer, registerKey bool, callback js.Func[func(response js.ArrayBuffer)]) (ret js.Void) {
   504  	bindings.CallChallengeMachineKey(
   505  		js.Pointer(&ret),
   506  		challenge.Ref(),
   507  		js.Bool(bool(registerKey)),
   508  		callback.Ref(),
   509  	)
   510  
   511  	return
   512  }
   513  
   514  // TryChallengeMachineKey calls the function "WEBEXT.enterprise.platformKeys.challengeMachineKey"
   515  // in a try/catch block and returns (_, err, ok = false) when it went through
   516  // the catch clause.
   517  func TryChallengeMachineKey(challenge js.ArrayBuffer, registerKey bool, callback js.Func[func(response js.ArrayBuffer)]) (ret js.Void, exception js.Any, ok bool) {
   518  	ok = js.True == bindings.TryChallengeMachineKey(
   519  		js.Pointer(&ret), js.Pointer(&exception),
   520  		challenge.Ref(),
   521  		js.Bool(bool(registerKey)),
   522  		callback.Ref(),
   523  	)
   524  
   525  	return
   526  }
   527  
   528  // HasFuncChallengeUserKey returns true if the function "WEBEXT.enterprise.platformKeys.challengeUserKey" exists.
   529  func HasFuncChallengeUserKey() bool {
   530  	return js.True == bindings.HasFuncChallengeUserKey()
   531  }
   532  
   533  // FuncChallengeUserKey returns the function "WEBEXT.enterprise.platformKeys.challengeUserKey".
   534  func FuncChallengeUserKey() (fn js.Func[func(challenge js.ArrayBuffer, registerKey bool, callback js.Func[func(response js.ArrayBuffer)])]) {
   535  	bindings.FuncChallengeUserKey(
   536  		js.Pointer(&fn),
   537  	)
   538  	return
   539  }
   540  
   541  // ChallengeUserKey calls the function "WEBEXT.enterprise.platformKeys.challengeUserKey" directly.
   542  func ChallengeUserKey(challenge js.ArrayBuffer, registerKey bool, callback js.Func[func(response js.ArrayBuffer)]) (ret js.Void) {
   543  	bindings.CallChallengeUserKey(
   544  		js.Pointer(&ret),
   545  		challenge.Ref(),
   546  		js.Bool(bool(registerKey)),
   547  		callback.Ref(),
   548  	)
   549  
   550  	return
   551  }
   552  
   553  // TryChallengeUserKey calls the function "WEBEXT.enterprise.platformKeys.challengeUserKey"
   554  // in a try/catch block and returns (_, err, ok = false) when it went through
   555  // the catch clause.
   556  func TryChallengeUserKey(challenge js.ArrayBuffer, registerKey bool, callback js.Func[func(response js.ArrayBuffer)]) (ret js.Void, exception js.Any, ok bool) {
   557  	ok = js.True == bindings.TryChallengeUserKey(
   558  		js.Pointer(&ret), js.Pointer(&exception),
   559  		challenge.Ref(),
   560  		js.Bool(bool(registerKey)),
   561  		callback.Ref(),
   562  	)
   563  
   564  	return
   565  }
   566  
   567  // HasFuncGetCertificates returns true if the function "WEBEXT.enterprise.platformKeys.getCertificates" exists.
   568  func HasFuncGetCertificates() bool {
   569  	return js.True == bindings.HasFuncGetCertificates()
   570  }
   571  
   572  // FuncGetCertificates returns the function "WEBEXT.enterprise.platformKeys.getCertificates".
   573  func FuncGetCertificates() (fn js.Func[func(tokenId js.String, callback js.Func[func(certificates js.Array[js.ArrayBuffer])])]) {
   574  	bindings.FuncGetCertificates(
   575  		js.Pointer(&fn),
   576  	)
   577  	return
   578  }
   579  
   580  // GetCertificates calls the function "WEBEXT.enterprise.platformKeys.getCertificates" directly.
   581  func GetCertificates(tokenId js.String, callback js.Func[func(certificates js.Array[js.ArrayBuffer])]) (ret js.Void) {
   582  	bindings.CallGetCertificates(
   583  		js.Pointer(&ret),
   584  		tokenId.Ref(),
   585  		callback.Ref(),
   586  	)
   587  
   588  	return
   589  }
   590  
   591  // TryGetCertificates calls the function "WEBEXT.enterprise.platformKeys.getCertificates"
   592  // in a try/catch block and returns (_, err, ok = false) when it went through
   593  // the catch clause.
   594  func TryGetCertificates(tokenId js.String, callback js.Func[func(certificates js.Array[js.ArrayBuffer])]) (ret js.Void, exception js.Any, ok bool) {
   595  	ok = js.True == bindings.TryGetCertificates(
   596  		js.Pointer(&ret), js.Pointer(&exception),
   597  		tokenId.Ref(),
   598  		callback.Ref(),
   599  	)
   600  
   601  	return
   602  }
   603  
   604  // HasFuncGetTokens returns true if the function "WEBEXT.enterprise.platformKeys.getTokens" exists.
   605  func HasFuncGetTokens() bool {
   606  	return js.True == bindings.HasFuncGetTokens()
   607  }
   608  
   609  // FuncGetTokens returns the function "WEBEXT.enterprise.platformKeys.getTokens".
   610  func FuncGetTokens() (fn js.Func[func(callback js.Func[func(tokens js.Array[Token])])]) {
   611  	bindings.FuncGetTokens(
   612  		js.Pointer(&fn),
   613  	)
   614  	return
   615  }
   616  
   617  // GetTokens calls the function "WEBEXT.enterprise.platformKeys.getTokens" directly.
   618  func GetTokens(callback js.Func[func(tokens js.Array[Token])]) (ret js.Void) {
   619  	bindings.CallGetTokens(
   620  		js.Pointer(&ret),
   621  		callback.Ref(),
   622  	)
   623  
   624  	return
   625  }
   626  
   627  // TryGetTokens calls the function "WEBEXT.enterprise.platformKeys.getTokens"
   628  // in a try/catch block and returns (_, err, ok = false) when it went through
   629  // the catch clause.
   630  func TryGetTokens(callback js.Func[func(tokens js.Array[Token])]) (ret js.Void, exception js.Any, ok bool) {
   631  	ok = js.True == bindings.TryGetTokens(
   632  		js.Pointer(&ret), js.Pointer(&exception),
   633  		callback.Ref(),
   634  	)
   635  
   636  	return
   637  }
   638  
   639  // HasFuncImportCertificate returns true if the function "WEBEXT.enterprise.platformKeys.importCertificate" exists.
   640  func HasFuncImportCertificate() bool {
   641  	return js.True == bindings.HasFuncImportCertificate()
   642  }
   643  
   644  // FuncImportCertificate returns the function "WEBEXT.enterprise.platformKeys.importCertificate".
   645  func FuncImportCertificate() (fn js.Func[func(tokenId js.String, certificate js.ArrayBuffer, callback js.Func[func()])]) {
   646  	bindings.FuncImportCertificate(
   647  		js.Pointer(&fn),
   648  	)
   649  	return
   650  }
   651  
   652  // ImportCertificate calls the function "WEBEXT.enterprise.platformKeys.importCertificate" directly.
   653  func ImportCertificate(tokenId js.String, certificate js.ArrayBuffer, callback js.Func[func()]) (ret js.Void) {
   654  	bindings.CallImportCertificate(
   655  		js.Pointer(&ret),
   656  		tokenId.Ref(),
   657  		certificate.Ref(),
   658  		callback.Ref(),
   659  	)
   660  
   661  	return
   662  }
   663  
   664  // TryImportCertificate calls the function "WEBEXT.enterprise.platformKeys.importCertificate"
   665  // in a try/catch block and returns (_, err, ok = false) when it went through
   666  // the catch clause.
   667  func TryImportCertificate(tokenId js.String, certificate js.ArrayBuffer, callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) {
   668  	ok = js.True == bindings.TryImportCertificate(
   669  		js.Pointer(&ret), js.Pointer(&exception),
   670  		tokenId.Ref(),
   671  		certificate.Ref(),
   672  		callback.Ref(),
   673  	)
   674  
   675  	return
   676  }
   677  
   678  // HasFuncRemoveCertificate returns true if the function "WEBEXT.enterprise.platformKeys.removeCertificate" exists.
   679  func HasFuncRemoveCertificate() bool {
   680  	return js.True == bindings.HasFuncRemoveCertificate()
   681  }
   682  
   683  // FuncRemoveCertificate returns the function "WEBEXT.enterprise.platformKeys.removeCertificate".
   684  func FuncRemoveCertificate() (fn js.Func[func(tokenId js.String, certificate js.ArrayBuffer, callback js.Func[func()])]) {
   685  	bindings.FuncRemoveCertificate(
   686  		js.Pointer(&fn),
   687  	)
   688  	return
   689  }
   690  
   691  // RemoveCertificate calls the function "WEBEXT.enterprise.platformKeys.removeCertificate" directly.
   692  func RemoveCertificate(tokenId js.String, certificate js.ArrayBuffer, callback js.Func[func()]) (ret js.Void) {
   693  	bindings.CallRemoveCertificate(
   694  		js.Pointer(&ret),
   695  		tokenId.Ref(),
   696  		certificate.Ref(),
   697  		callback.Ref(),
   698  	)
   699  
   700  	return
   701  }
   702  
   703  // TryRemoveCertificate calls the function "WEBEXT.enterprise.platformKeys.removeCertificate"
   704  // in a try/catch block and returns (_, err, ok = false) when it went through
   705  // the catch clause.
   706  func TryRemoveCertificate(tokenId js.String, certificate js.ArrayBuffer, callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) {
   707  	ok = js.True == bindings.TryRemoveCertificate(
   708  		js.Pointer(&ret), js.Pointer(&exception),
   709  		tokenId.Ref(),
   710  		certificate.Ref(),
   711  		callback.Ref(),
   712  	)
   713  
   714  	return
   715  }