text:
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"math/rand"
	"net/http"
	"os"
	"time"

	"github.com/qlik-oss/enigma-go/v4"
)

func main() {
	// Fetch the QCS_HOST and QCS_API_KEY from the environment variables
	qcsHost := os.Getenv("QCS_HOST")
	qcsApiKey := os.Getenv("QCS_API_KEY")

	ctx := context.Background()
	rand.Seed(time.Now().UnixNano())

	// Connect to Qlik Cloud tenant and create a session document:
	global, err := enigma.Dialer{}.Dial(ctx, fmt.Sprintf("wss://%s/app/SessionApp_%v", qcsHost, rand.Int()), http.Header{
		"Authorization": []string{fmt.Sprintf("Bearer %s", qcsApiKey)},
	})
	if err != nil {
		fmt.Println(err)
		panic(err)
	}
	// When we leave this function disconnect from Qlik Associative Engine
	defer global.DisconnectFromServer()

	// Open a session app that only lives in memory
	app, err := global.GetActiveDoc(ctx)
	if err != nil {
		fmt.Println(err)
		panic(err)
	}

	err = app.SetScript(ctx, `
	Characters:
	Load Chr(RecNo()+Ord('A')-1) as Alpha, RecNo() as Num autogenerate 26;

	ASCII:
	Load
	 if(RecNo()>=65 and RecNo()<=90,RecNo()-64) as Num,
	 Chr(RecNo()) as AsciiAlpha,
	 RecNo() as AsciiNum
	autogenerate 255
	 Where (RecNo()>=32 and RecNo()<=126) or RecNo()>=160 ;

	Transactions:
	Load
	 TransLineID,
	 TransID,
	 mod(TransID,26)+1 as Num,
	 Pick(Ceil(3*Rand1),'A','B','C') as Dim1,
	 Pick(Ceil(6*Rand1),'a','b','c','d','e','f') as Dim2,
	 Pick(Ceil(3*Rand()),'X','Y','Z') as Dim3,
	 Round(1000*Rand()*Rand()*Rand1) as Expression1,
	 Round(  10*Rand()*Rand()*Rand1) as Expression2,
	 Round(Rand()*Rand1,0.00001) as Expression3;
	Load
	 Rand() as Rand1,
	 IterNo() as TransLineID,
	 RecNo() as TransID
	Autogenerate 1000
	 While Rand()<=0.5 or IterNo()=1;`)
	if err != nil {
		fmt.Println(err)
		panic(err)
	}

	reloadDone := make(chan struct{})
	// The GetProgress call further down needs the protocol request id. So we reserve a request id that is used
	// in the DoReload request so we know what it will be.
	ctxWithReservedRequestID, reservedRequestID := app.WithReservedRequestID(ctx)
	// Monitor the reload
	go func() {
		for {
			select {
			case <-reloadDone:
				return
			default:
				time.Sleep(1000)
				// Get the progress using the request id we reserved for the reload
				progress, err := global.GetProgress(ctx, reservedRequestID)
				if err != nil {
					fmt.Println(err)
					return
				}
				progressBytes, _ := json.MarshalIndent(progress, "", "\t")
				fmt.Println(string(progressBytes))
			}

		}
	}()

	// Do the reload in a separate goroutine
	reloadSuccessful, err := app.DoReload(ctxWithReservedRequestID, 0, false, false)

	if err != nil {
		fmt.Println("Error when reloading app", err)
		panic(err)
	}

	if !reloadSuccessful {
		panic("DoReload was not successful!")
	}

	close(reloadDone)
	fmt.Println("Reload Done")

	object, err := app.CreateSessionObject(ctx, &enigma.GenericObjectProperties{
		Info: &enigma.NxInfo{
			Type: "GenericObject",
			Id:   "TransactionsExample",
		},
		HyperCubeDef: &enigma.HyperCubeDef{
			Dimensions: []*enigma.NxDimension{{
				Def: &enigma.NxInlineDimensionDef{
					FieldDefs: []string{
						"Dim1",
					},
					SortCriterias: []*enigma.SortCriteria{{
						SortByAscii: 1,
					}},
				}},
			},
			InitialDataFetch: []*enigma.NxPage{{0, 0, 10, 10}},
		},
	})
	if err != nil {
		fmt.Println(err)
		panic(err)
	}
	layout, err := object.GetLayout(ctx)
	cell := layout.HyperCube.DataPages[0].Matrix[1][0]
	fmt.Println(cell.Text)
	// Output: B
}

license: MIT

repository: qlik-oss/enigma-go

license_type: permissive

repo_name: qlik-oss/enigma-go

branch_name: refs/heads/master

gha_license_id: MIT

gha_language: Go

extension: go


text:
const compileShader = (gl, type, source) => {
    const shader = gl.createShader(type);
    gl.shaderSource(shader, source);
    gl.compileShader(shader);

    const success = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
    if(success) {
        return shader;
    }
    const typeShader = (35633 === type) ? 'VertexShader' : 'FragmentShader';
    console.error(`Algún error con el ${typeShader}: `, gl.getShaderInfoLog(shader));
    gl.deleteShader(shader)
}

export default compileShader;

repository: DeybisMelendez/nacatamal-on

repo_name: DeybisMelendez/nacatamal-on

extension: js


text:
DESCRIPTION = "Rover Buttons Service"
AUTHOR = "Pedro Cuadra"

LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${WORKDIR}/git/LICENSE;md5=86d3f3a95c324c9479bd8986968f4327"

SRC_URI = "gitsm://github.com/app4mc-rover/rover-services.git;branch=master"
SRCREV = "3059cfba488515c92502b34979c77ae98303f472"

PV_append = "+r${SRCREV}"
S = "${WORKDIR}/git/service/roverbuttons"
B = "${WORKDIR}/build"

DEPENDS += " rover-app"
RDEPENDS_${PN} += " rover-app"

inherit cmake aglwgt pkgconfig

extension: bb


text:
SUMMARY = "PolicyKit Authorization Framework"
DESCRIPTION = "The polkit package is an application-level toolkit for defining and handling the policy that allows unprivileged processes to speak to privileged processes."
HOMEPAGE = "http://www.freedesktop.org/wiki/Software/polkit"
LICENSE = "LGPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://COPYING;md5=155db86cdbafa7532b41f390409283eb \
                    file://src/polkit/polkit.h;beginline=1;endline=20;md5=0a8630b0133176d0504c87a0ded39db4"

DEPENDS = "expat glib-2.0 intltool-native"

inherit autotools gtk-doc pkgconfig useradd systemd gobject-introspection features_check

REQUIRED_DISTRO_FEATURES = "polkit"

PACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
                 ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', \
                    bb.utils.contains('DISTRO_FEATURES', 'x11', 'consolekit', '', d), d)} \
                 mozjs \
                "

PACKAGECONFIG[pam] = "--with-authfw=pam,--with-authfw=shadow,libpam,libpam"
PACKAGECONFIG[systemd] = "--enable-libsystemd-login=yes --with-systemdsystemunitdir=${systemd_unitdir}/system/,--enable-libsystemd-login=no --with-systemdsystemunitdir=,systemd"
# there is no --enable/--disable option for consolekit and it's not picked by shlibs, so add it to RDEPENDS
PACKAGECONFIG[consolekit] = ",,,consolekit"

# Default to mozjs javascript library
PACKAGECONFIG[mozjs] = ",,mozjs-91,,,duktape"
# duktape javascript engine is much smaller and faster but is not compatible with
# same javascript standards as mozjs. For example array.includes() function is not
# supported. Test rule compatibility when switching to duktape.
PACKAGECONFIG[duktape] = "--with-duktape,,duktape,,,mozjs"

MOZJS_PATCHES = "\
    file://0002-jsauthority-port-to-mozjs-91.patch \
    file://0003-jsauthority-ensure-to-call-JS_Init-and-JS_ShutDown-e.patch \
"
DUKTAPE_PATCHES = "file://0003-Added-support-for-duktape-as-JS-engine.patch"
DUKTAPE_NG_PATCHES = "file://0005-Make-netgroup-support-optional-duktape.patch"
PAM_SRC_URI = "file://polkit-1_pam.patch"
SRC_URI = "http://www.freedesktop.org/software/polkit/releases/polkit-${PV}.tar.gz \
           ${@bb.utils.contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} \
           ${@bb.utils.contains('PACKAGECONFIG', 'mozjs', '${MOZJS_PATCHES}', '', d)} \
           ${@bb.utils.contains('PACKAGECONFIG', 'duktape', '${DUKTAPE_PATCHES}', '', d)} \
           file://0001-pkexec-local-privilege-escalation-CVE-2021-4034.patch \
           file://0002-CVE-2021-4115-GHSL-2021-077-fix.patch \
           file://0004-Make-netgroup-support-optional.patch \
           ${@bb.utils.contains('PACKAGECONFIG', 'duktape', '${DUKTAPE_NG_PATCHES}', '', d)} \
           "
SRC_URI[sha256sum] = "c8579fdb86e94295404211285fee0722ad04893f0213e571bd75c00972fd1f5c"

EXTRA_OECONF = "--with-os-type=moblin \
                --disable-man-pages \
                --disable-libelogind \
               "

do_configure:prepend () {
    rm -f ${S}/buildutil/lt*.m4 ${S}/buildutil/libtool.m4
}

do_compile:prepend () {
    export GIR_EXTRA_LIBS_PATH="${B}/src/polkit/.libs"
}

PACKAGES =+ "${PN}-examples"

FILES:${PN}:append = " \
    ${libdir}/${BPN}-1 \
    ${nonarch_libdir}/${BPN}-1 \
    ${datadir}/dbus-1 \
    ${datadir}/${BPN}-1 \
    ${datadir}/gettext \
"

FILES:${PN}-examples = "${bindir}/*example*"

USERADD_PACKAGES = "${PN}"
USERADD_PARAM:${PN} = "--system --no-create-home --user-group --home-dir ${sysconfdir}/${BPN}-1 --shell /bin/nologin polkitd"

SYSTEMD_SERVICE:${PN} = "${BPN}.service"
SYSTEMD_AUTO_ENABLE = "disable"

repository: openembedded/meta-openembedded

repo_name: openembedded/meta-openembedded

gha_language: BitBake


text:
package validator

import (
	"errors"
	"sync/atomic"

	objects "github.com/d5/tengo/v2"
)

var (
	// IsTestExecution if test is executed under test conditions
	IsTestExecution atomic.Value

	exchError = &objects.String{
		Value: "",
	}
	errTestFailed = errors.New("test failed")
)

// Wrapper for validator interface
type Wrapper struct{}

repository: thrasher-corp/gocryptotrader

repo_name: thrasher-corp/gocryptotrader


text:
@InProceedings{tang16b,
  supplementary = {Supplementary:tang16b-supp.pdf},
  title = {On Lloyd's Algorithm: New Theoretical Insights for Clustering in Practice},
  author = {Tang, Cheng and Monteleoni, Claire},
  pages = {1280-1289},
  abstract = {We provide new analyses of Lloyd's algorithm (1982), commonly known as the $k$-means clustering algorithm. Kumar and Kannan (2010) showed that running $k$-SVD followed by a constant approximation $k$-means algorithm, and then Lloyd's algorithm, will correctly cluster nearly all of the dataset with respect to the optimal clustering, provided the dataset satisfies a deterministic clusterability assumption. This method is viewed as the "Swiss Army knife" for clustering problems, subsuming popular generative models such as Gaussian mixtures. However, it is tailored to high dimensional data, i.e., when $d \gg k$ . We analyze Lloyd's algorithm for general d without using the spectral projection, which leads to a weaker assumption in the case $d < k$. Surprisingly, we show that a simple and scalable heuristic that combines random sampling with Single-Linkage serves as a good seeding algorithm for Lloyd's algorithm under this assumption. We then study stopping criteria for Lloyd's algorithm under the lens of clusterability, accompanied by controlled simulations.},
}

repository: mreid/papersite

repo_name: mreid/papersite

gha_language: TeX

extension: bib


text:
/*
Copyright 2016 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package bsutil package will eventually be renamed to kubeadm package after getting rid of older one
package bsutil

import (
	"fmt"
	"os/exec"
	"path"
	"runtime"
	"strings"

	"github.com/pkg/errors"
	"golang.org/x/sync/errgroup"

	"k8s.io/klog/v2"
	"k8s.io/minikube/pkg/minikube/command"
	"k8s.io/minikube/pkg/minikube/config"
	"k8s.io/minikube/pkg/minikube/constants"
	"k8s.io/minikube/pkg/minikube/download"
	"k8s.io/minikube/pkg/minikube/machine"
	"k8s.io/minikube/pkg/minikube/sysinit"
	"k8s.io/minikube/pkg/minikube/vmpath"
)

// TransferBinaries transfers all required Kubernetes binaries
func TransferBinaries(cfg config.KubernetesConfig, c command.Runner, sm sysinit.Manager, binariesURL string) error {
	ok, err := binariesExist(cfg, c)
	if err == nil && ok {
		klog.Info("Found k8s binaries, skipping transfer")
		return nil
	}
	klog.Infof("Didn't find k8s binaries: %v\nInitiating transfer...", err)

	dir := binRoot(cfg.KubernetesVersion)
	_, err = c.RunCmd(exec.Command("sudo", "mkdir", "-p", dir))
	if err != nil {
		return err
	}

	var g errgroup.Group
	for _, name := range constants.KubernetesReleaseBinaries {
		name := name
		g.Go(func() error {
			src, err := download.Binary(name, cfg.KubernetesVersion, "linux", runtime.GOARCH, binariesURL)
			if err != nil {
				return errors.Wrapf(err, "downloading %s", name)
			}

			if name == "kubelet" && sm.Active(name) {
				if err := sm.ForceStop(name); err != nil {
					klog.Errorf("unable to stop kubelet: %v", err)
				}
			}

			dst := path.Join(dir, name)
			if err := machine.CopyBinary(c, src, dst); err != nil {
				return errors.Wrapf(err, "copybinary %s -> %s", src, dst)
			}
			return nil
		})
	}
	return g.Wait()
}

// binariesExist returns true if the binaries already exist
func binariesExist(cfg config.KubernetesConfig, c command.Runner) (bool, error) {
	dir := binRoot(cfg.KubernetesVersion)
	rr, err := c.RunCmd(exec.Command("sudo", "ls", dir))
	if err != nil {
		return false, err
	}
	stdout := rr.Stdout.String()
	foundBinaries := map[string]struct{}{}
	for _, binary := range strings.Split(stdout, "\n") {
		foundBinaries[binary] = struct{}{}
	}
	for _, name := range constants.KubernetesReleaseBinaries {
		if _, ok := foundBinaries[name]; !ok {
			return false, fmt.Errorf("didn't find preexisting %s", name)
		}
	}
	return true, nil
}

// binRoot returns the persistent path binaries are stored in
func binRoot(version string) string {
	return path.Join(vmpath.GuestPersistentDir, "binaries", version)
}

repository: kubernetes/minikube

repo_name: kubernetes/minikube


text:
package app

import (
	"net"
	"net/http"
	"net/http/pprof"
	"os"
	"os/signal"
	"strconv"
	"syscall"

	"github.com/adohe/kube2haproxy/app/options"
	"github.com/adohe/kube2haproxy/proxy/controller"
	"github.com/adohe/kube2haproxy/proxy/template"

	kubeclient "k8s.io/kubernetes/pkg/client/unversioned"
	"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
	clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
	"k8s.io/kubernetes/pkg/healthz"
	"k8s.io/kubernetes/pkg/util/wait"

	"github.com/golang/glog"
	"github.com/prometheus/client_golang/prometheus"
)

type ProxyServer struct {
	Client     *kubeclient.Client
	Config     *options.ProxyServerConfig
	Controller *controller.ProxyController
}

func NewProxyServer(
	client *kubeclient.Client,
	controller *controller.ProxyController,
	config *options.ProxyServerConfig,
) (*ProxyServer, error) {
	return &ProxyServer{
		Client:     client,
		Config:     config,
		Controller: controller,
	}, nil
}

// NewProxyServerDefault creates a new ProxyServer object with default parameters.
func NewProxyServerDefault(config *options.ProxyServerConfig) (*ProxyServer, error) {
	// Create a Kube Client
	// define api config source
	if config.Kubeconfig == "" && config.Master == "" {
		glog.Warningf("Neither --kubeconfig nor --master was specified. Using default API client. This might not work")
	}
	// This creates a client, first loading any specified kubeconfig
	// file, and then overriding the Master flag, if specified.
	kubeconfig, err := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
		&clientcmd.ClientConfigLoadingRules{ExplicitPath: config.Kubeconfig},
		&clientcmd.ConfigOverrides{ClusterInfo: clientcmdapi.Cluster{Server: config.Master}}).ClientConfig()
	if err != nil {
		return nil, err
	}

	// Override kubeconfig qps/burst settings from flags
	kubeconfig.QPS = config.KubeAPIQPS
	kubeconfig.Burst = config.KubeAPIBurst

	client, err := kubeclient.New(kubeconfig)
	if err != nil {
		glog.Fatalf("Invalid API configuration: %v", err)
	}

	proxierConfig := template.ProxierConfig{config.Device, config.KeepalivedConfig, config.HaproxyConfig}
	proxier, err := template.NewProxier(proxierConfig)
	if err != nil {
		return nil, err
	}

	controller := controller.New(client, proxier, config.SyncPeriod)
	return NewProxyServer(client, controller, config)
}

// Run runs the specified ProxyServer. This should never exit.
func (s *ProxyServer) Run() error {
	if s.Config.Port > 0 {
		go func() {
			mux := http.NewServeMux()
			healthz.InstallHandler(mux)
			if s.Config.EnableProfiling {
				mux.HandleFunc("/debug/pprof/", pprof.Index)
				mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
				mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
			}
			mux.Handle("/metrics", prometheus.Handler())

			server := &http.Server{
				Addr:    net.JoinHostPort(s.Config.Address, strconv.Itoa(s.Config.Port)),
				Handler: mux,
			}
			glog.Fatal(server.ListenAndServe())
		}()
	}

	s.Controller.Run(wait.NeverStop, registerOSSignals())
	return nil
}

func registerOSSignals() chan os.Signal {
	c := make(chan os.Signal, 2)
	signal.Notify(c, syscall.SIGUSR1, syscall.SIGUSR2)
	return c
}


text:
require recipes-kernel/linux/linux-yocto.inc

KERNEL_IMAGETYPE = "zImage"

COMPATIBLE_MACHINE = "duovero"

RDEPENDS_kernel-base += "kernel-devicetree"

KERNEL_DEVICETREE = " \
    omap4-duovero-parlor.dtb \
"

LINUX_VERSION = "3.18"
LINUX_VERSION_EXTENSION = "-jumpnow"

FILESEXTRAPATHS_prepend := "${THISDIR}/linux-stable-3.18:"

S = "${WORKDIR}/git"

PR = "r1"

PV = "3.18.86"
SRCREV = "1d2acf22c2539c568e0a4bd63bf464e10acd8070"
SRC_URI = " \
    git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git;branch=linux-3.18.y \
    file://defconfig \
    file://0001-duovero-Bind-vdac-regulator-to-hdmi-node.patch \
    file://0002-spidev-Add-a-generic-compatible-id.patch \
"


text:
package accesscontrol_test

import (
	"context"
	"crypto/rand"
	"crypto/rsa"
	"crypto/x509"
	"encoding/pem"
	"fmt"
	"net/http"
	"net/http/httptest"
	"reflect"
	"strings"
	"testing"

	"github.com/dgrijalva/jwt-go/v4"
	"github.com/hashicorp/hcl/v2"
	"github.com/hashicorp/hcl/v2/hcltest"
	"github.com/zclconf/go-cty/cty"

	ac "github.com/avenga/couper/accesscontrol"
	acjwt "github.com/avenga/couper/accesscontrol/jwt"
	"github.com/avenga/couper/config/configload"
	"github.com/avenga/couper/config/reader"
	"github.com/avenga/couper/config/request"
	"github.com/avenga/couper/config/runtime"
	"github.com/avenga/couper/errors"
	"github.com/avenga/couper/eval"
	"github.com/avenga/couper/internal/test"
	logrustest "github.com/sirupsen/logrus/hooks/test"
)

func Test_JWT_NewJWT_RSA(t *testing.T) {
	helper := test.New(t)

	type fields struct {
		algorithm      string
		claims         hcl.Expression
		claimsRequired []string
		pubKey         []byte
		pubKeyPath     string
	}

	privKey, err := rsa.GenerateKey(rand.Reader, 2048)
	helper.Must(err)

	bytes, err := x509.MarshalPKIXPublicKey(&privKey.PublicKey)
	helper.Must(err)

	pubKeyBytesPKIX := pem.EncodeToMemory(&pem.Block{
		Type:  "PUBLIC KEY",
		Bytes: bytes,
	})
	pubKeyBytesPKCS1 := pem.EncodeToMemory(&pem.Block{
		Type:  "RSA PUBLIC KEY",
		Bytes: x509.MarshalPKCS1PublicKey(&privKey.PublicKey),
	})
	privKeyBytes := pem.EncodeToMemory(&pem.Block{
		Type:  "RSA PRIVATE KEY",
		Bytes: x509.MarshalPKCS1PrivateKey(privKey),
	})
	// created using
	// openssl req -new -newkey rsa:1024 -days 100000 -nodes -x509
	certBytes := []byte(`-----BEGIN CERTIFICATE-----
MIICaDCCAdGgAwIBAgIUZe+V/eBcYEaoORX8mfsyR8LqY/kwDQYJKoZIhvcNAQEL
BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAgFw0yMTA0MTIxMzI1MzRaGA8yMjk1
MDEyNjEzMjUzNFowRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0B
AQEFAAOBjQAwgYkCgYEA2m79uRP+f/L6YgCuQoAiY6Qs5pccKR4DNfb+vQOsO+xx
ZxWrY3RLSLOYKCBybHClz0JLT61duq7yfOl+03lYE6wTdy5XN1PGoijITj3cA6g1
Eah6/CirrDVqEVIng+5lsw/Qws1gOOkHaCdfkL85Trm4AWqppgFgIc/wafHZjekC
AwEAAaNTMFEwHQYDVR0OBBYEFCAUN20ma8sVaz1KZttyofv6tDZdMB8GA1UdIwQY
MBaAFCAUN20ma8sVaz1KZttyofv6tDZdMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI
hvcNAQELBQADgYEADyu05JNvWly50lvUksx85QwEMb7oZha6aov/9eslJnHD10Zu
QolLGgj3tz4NbDEitq+zKMr0uTHvP1Vyu1mXAflcpYcJA4ZmuB3Oj39e0U0gnmr/
1T2dX1uHaAWl3pCmkRH1Dmpsx2sHllN/yizHpve2rrVpM9ZMXEdPxnzNNFE=
-----END CERTIFICATE-----`)

	for _, signingMethod := range []jwt.SigningMethod{
		jwt.SigningMethodRS256, jwt.SigningMethodRS384, jwt.SigningMethodRS512,
	} {
		alg := signingMethod.Alg()
		tests := []struct {
			name    string
			fields  fields
			wantErr string
		}{
			{"missing key-file path", fields{}, "configuration error: jwt key: read error: required: configured attribute or file"},
			{"missing key-file", fields{pubKeyPath: "./not-there.file"}, "not-there.file: no such file or directory"},
			{"PKIX", fields{
				algorithm: alg,
				pubKey:    pubKeyBytesPKIX,
			}, ""},
			{"PKCS1", fields{
				algorithm: alg,
				pubKey:    pubKeyBytesPKCS1,
			}, ""},
			{"Cert", fields{
				algorithm: alg,
				pubKey:    certBytes,
			}, ""},
			{"Priv", fields{
				algorithm: alg,
				pubKey:    privKeyBytes,
			}, "key is not a valid RSA public key"},
		}

		for _, tt := range tests {
			t.Run(fmt.Sprintf("%v / %s", signingMethod, tt.name), func(subT *testing.T) {
				key, rerr := reader.ReadFromAttrFile("jwt key", string(tt.fields.pubKey), tt.fields.pubKeyPath)
				if rerr != nil {
					logErr := rerr.(errors.GoError)
					if tt.wantErr != "" && !strings.HasSuffix(logErr.LogError(), tt.wantErr) {
						subT.Errorf("\nWant:\t%q\nGot:\t%q", tt.wantErr, logErr.LogError())
					} else if tt.wantErr == "" {
						subT.Fatal(logErr.LogError())
					}
					return
				}

				j, jerr := ac.NewJWT(&ac.JWTOptions{
					Algorithm:      tt.fields.algorithm,
					Claims:         tt.fields.claims,
					ClaimsRequired: tt.fields.claimsRequired,
					Name:           "test_ac",
					Key:            key,
					Source:         ac.NewJWTSource("", "Authorization", nil),
				})
				if jerr != nil {
					if tt.wantErr != jerr.Error() {
						subT.Errorf("error: %v, want: %v", jerr.Error(), tt.wantErr)
					}
				} else if tt.wantErr != "" {
					subT.Errorf("error expected: %v", tt.wantErr)
				}
				if tt.wantErr == "" && j == nil {
					subT.Errorf("JWT struct expected")
				}
			})
		}
	}
}

func Test_JWT_Validate(t *testing.T) {
	type fields struct {
		algorithm      acjwt.Algorithm
		claims         map[string]string
		claimsRequired []string
		source         ac.JWTSource
		pubKey         []byte
	}

	for _, signingMethod := range []jwt.SigningMethod{
		jwt.SigningMethodRS256, jwt.SigningMethodRS384, jwt.SigningMethodRS512,
		jwt.SigningMethodHS256, jwt.SigningMethodHS384, jwt.SigningMethodHS512,
	} {

		pubKeyBytes, privKey := newRSAKeyPair()

		tok := jwt.NewWithClaims(signingMethod, jwt.MapClaims{
			"aud":     "peter",
			"test123": "value123",
		})
		var token string
		var tokenErr error

		algo := acjwt.NewAlgorithm(signingMethod.Alg())

		if algo.IsHMAC() {
			pubKeyBytes = []byte("mySecretK3y")
			token, tokenErr = tok.SignedString(pubKeyBytes)
		} else {
			token, tokenErr = tok.SignedString(privKey)
		}

		if tokenErr != nil {
			t.Error(tokenErr)
		}

		tests := []struct {
			name    string
			fields  fields
			req     *http.Request
			wantErr bool
		}{
			{"src: header /w empty bearer", fields{
				algorithm: algo,
				source:    ac.NewJWTSource("", "Authorization", nil),
				pubKey:    pubKeyBytes,
			}, httptest.NewRequest(http.MethodGet, "/", nil), true},
			{"src: header /w valid bearer", fields{
				algorithm: algo,
				source:    ac.NewJWTSource("", "Authorization", nil),
				pubKey:    pubKeyBytes,
			}, setCookieAndHeader(httptest.NewRequest(http.MethodGet, "/", nil), "Authorization", "BeAreR "+token), false},
			{"src: header /w no cookie", fields{
				algorithm: algo,
				source:    ac.NewJWTSource("token", "", nil),
				pubKey:    pubKeyBytes,
			}, httptest.NewRequest(http.MethodGet, "/", nil), true},
			{"src: header /w empty cookie", fields{
				algorithm: algo,
				source:    ac.NewJWTSource("token", "", nil),
				pubKey:    pubKeyBytes,
			}, setCookieAndHeader(httptest.NewRequest(http.MethodGet, "/", nil), "token", ""), true},
			{"src: header /w valid cookie", fields{
				algorithm: algo,
				source:    ac.NewJWTSource("token", "", nil),
				pubKey:    pubKeyBytes,
			}, setCookieAndHeader(httptest.NewRequest(http.MethodGet, "/", nil), "token", token), false},
			{"src: header /w valid bearer & claims", fields{
				algorithm: algo,
				claims: map[string]string{
					"aud":     "peter",
					"test123": "value123",
				},
				claimsRequired: []string{"aud"},
				source:         ac.NewJWTSource("", "Authorization", nil),
				pubKey:         pubKeyBytes,
			}, setContext(setCookieAndHeader(httptest.NewRequest(http.MethodGet, "/", nil), "Authorization", "BeAreR "+token)), false},
			{"src: header /w valid bearer & w/o claims", fields{
				algorithm: algo,
				claims: map[string]string{
					"aud":  "peter",
					"cptn": "hook",
				},
				source: ac.NewJWTSource("", "Authorization", nil),
				pubKey: pubKeyBytes,
			}, setContext(setCookieAndHeader(httptest.NewRequest(http.MethodGet, "/", nil), "Authorization", "BeAreR "+token)), true},
			{"src: header /w valid bearer & w/o required claims", fields{
				algorithm: algo,
				claims: map[string]string{
					"aud": "peter",
				},
				claimsRequired: []string{"exp"},
				source:         ac.NewJWTSource("", "Authorization", nil),
				pubKey:         pubKeyBytes,
			}, setContext(setCookieAndHeader(httptest.NewRequest(http.MethodGet, "/", nil), "Authorization", "BeAreR "+token)), true},
			{
				"token_value number",
				fields{
					algorithm: algo,
					source:    ac.NewJWTSource("", "", hcltest.MockExprLiteral(cty.NumberIntVal(42))),
					pubKey:    pubKeyBytes,
				},
				setContext(httptest.NewRequest(http.MethodGet, "/", nil)),
				true,
			},
			{
				"token_value string",
				fields{
					algorithm:      algo,
					claims:         map[string]string{"aud": "peter", "test123": "value123"},
					claimsRequired: []string{"aud", "test123"},
					source:         ac.NewJWTSource("", "", hcltest.MockExprLiteral(cty.StringVal(token))),
					pubKey:         pubKeyBytes,
				},
				setContext(httptest.NewRequest(http.MethodGet, "/", nil)),
				false,
			},
		}
		for _, tt := range tests {
			t.Run(fmt.Sprintf("%v_%s", signingMethod, tt.name), func(subT *testing.T) {
				claimValMap := make(map[string]cty.Value)
				for k, v := range tt.fields.claims {
					claimValMap[k] = cty.StringVal(v)
				}
				j, err := ac.NewJWT(&ac.JWTOptions{
					Algorithm:      tt.fields.algorithm.String(),
					Claims:         hcl.StaticExpr(cty.ObjectVal(claimValMap), hcl.Range{}),
					ClaimsRequired: tt.fields.claimsRequired,
					Name:           "test_ac",
					Source:         tt.fields.source,
					Key:            tt.fields.pubKey,
				})
				if err != nil {
					subT.Error(err)
					return
				}

				if err = j.Validate(tt.req); (err != nil) != tt.wantErr {
					subT.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr)
				}

				if !tt.wantErr && tt.fields.claims != nil {
					acMap := tt.req.Context().Value(request.AccessControls).(map[string]interface{})
					if claims, ok := acMap["test_ac"]; !ok {
						subT.Errorf("Expected a configured access control name within request context")
					} else {
						claimsMap := claims.(map[string]interface{})
						for k, v := range tt.fields.claims {
							if claimsMap[k] != v {
								subT.Errorf("Claim does not match: %q want: %v, got: %v", k, v, claimsMap[k])
							}
						}
					}

				}
			})
		}
	}
}

func Test_JWT_yields_scopes(t *testing.T) {
	signingMethod := jwt.SigningMethodHS256
	algo := acjwt.NewAlgorithm(signingMethod.Alg())

	rolesMap := map[string][]string{
		"admin": {"foo", "bar", "baz"},
		"user1": {"foo"},
		"user2": {"bar"},
		"*":     {"default"},
	}

	tests := []struct {
		name       string
		scopeClaim string
		scope      interface{}
		rolesClaim string
		roles      interface{}
		wantErr    bool
		expScopes  []string
	}{
		{
			"scope: space-separated list",
			"scp",
			"foo bar",
			"",
			nil,
			false,
			[]string{"foo", "bar"},
		},
		{
			"scope: space-separated list, multiple",
			"scp",
			"foo bar foo",
			"",
			nil,
			false,
			[]string{"foo", "bar"},
		},
		{
			"scope: list of string",
			"scoop",
			[]string{"foo", "bar"},
			"",
			nil,
			false,
			[]string{"foo", "bar"},
		},
		{
			"scope: list of string, multiple",
			"scoop",
			[]string{"foo", "bar", "bar"},
			"",
			nil,
			false,
			[]string{"foo", "bar"},
		},
		{
			"scope: error: boolean",
			"scope",
			true,
			"",
			nil,
			true,
			[]string{},
		},
		{
			"scope: error: number",
			"scope",
			1.23,
			"",
			nil,
			true,
			[]string{},
		},
		{
			"scope: error: list of bool",
			"scope",
			[]bool{true, false},
			"",
			nil,
			true,
			[]string{},
		},
		{
			"scope: error: list of number",
			"scope",
			[]int{1, 2},
			"",
			nil,
			true,
			[]string{},
		},
		{
			"scope: error: mixed list",
			"scope",
			[]interface{}{"eins", 2},
			"",
			nil,
			true,
			[]string{},
		},
		{
			"scope: error: object",
			"scope",
			map[string]interface{}{"foo": 1, "bar": 1},
			"",
			nil,
			true,
			[]string{},
		},
		{
			"roles: single string",
			"",
			nil,
			"roles",
			"admin",
			false,
			[]string{"foo", "bar", "baz", "default"},
		},
		{
			"roles: space-separated list",
			"",
			nil,
			"roles",
			"user1 user2",
			false,
			[]string{"foo", "bar", "default"},
		},
		{
			"roles: space-separated list, multiple",
			"",
			nil,
			"roles",
			"user1 user2 user1",
			false,
			[]string{"foo", "bar", "default"},
		},
		{
			"roles: list of string",
			"",
			nil,
			"rollen",
			[]string{"user1", "user2"},
			false,
			[]string{"foo", "bar", "default"},
		},
		{
			"roles: list of string, multiple",
			"",
			nil,
			"rollen",
			[]string{"user1", "user2", "user2"},
			false,
			[]string{"foo", "bar", "default"},
		},
		{
			"roles: list of string, no additional 1",
			"",
			nil,
			"rollen",
			[]string{"admin", "user1"},
			false,
			[]string{"foo", "bar", "baz", "default"},
		},
		{
			"roles: list of string, no additional 2",
			"",
			nil,
			"rollen",
			[]string{"admin", "user2"},
			false,
			[]string{"foo", "bar", "baz", "default"},
		},
		{
			"roles: error: boolean",
			"",
			nil,
			"roles",
			true,
			true,
			[]string{},
		},
		{
			"roles: error: number",
			"",
			nil,
			"roles",
			1.23,
			true,
			[]string{},
		},
		{
			"roles: error: list of bool",
			"",
			nil,
			"roles",
			[]bool{true, false},
			true,
			[]string{},
		},
		{
			"roles: error: list of number",
			"",
			nil,
			"roles",
			[]int{1, 2},
			true,
			[]string{},
		},
		{
			"roles: error: mixed list",
			"",
			nil,
			"roles",
			[]interface{}{"eins", 2},
			true,
			[]string{},
		},
		{
			"roles: error: object",
			"",
			nil,
			"roles",
			map[string]interface{}{"foo": 1, "bar": 1},
			true,
			[]string{},
		},
		{
			"combi 1",
			"scope",
			"foo foo",
			"roles",
			[]string{"user2"},
			false,
			[]string{"foo", "bar", "default"},
		},
		{
			"combi 2",
			"scope",
			[]string{"foo", "bar"},
			"roles",
			"admin",
			false,
			[]string{"foo", "bar", "baz", "default"},
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(subT *testing.T) {
			claims := jwt.MapClaims{}
			if tt.scopeClaim != "" && tt.scope != nil {
				claims[tt.scopeClaim] = tt.scope
			}
			if tt.rolesClaim != "" && tt.roles != nil {
				claims[tt.rolesClaim] = tt.roles
			}
			tok := jwt.NewWithClaims(signingMethod, claims)
			pubKeyBytes := []byte("mySecretK3y")
			token, tokenErr := tok.SignedString(pubKeyBytes)
			if tokenErr != nil {
				subT.Error(tokenErr)
			}

			source := ac.NewJWTSource("", "Authorization", nil)
			j, err := ac.NewJWT(&ac.JWTOptions{
				Algorithm:  algo.String(),
				Name:       "test_ac",
				ScopeClaim: tt.scopeClaim,
				RolesClaim: tt.rolesClaim,
				RolesMap:   rolesMap,
				Source:     source,
				Key:        pubKeyBytes,
			})
			if err != nil {
				subT.Fatal(err)
			}

			req := setCookieAndHeader(httptest.NewRequest(http.MethodGet, "/", nil), "Authorization", "BeAreR "+token)

			if err = j.Validate(req); (err != nil) != tt.wantErr {
				subT.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr)
			}

			if !tt.wantErr {
				scopesList, ok := req.Context().Value(request.Scopes).([]string)
				if !ok {
					subT.Errorf("Expected scopes within request context")
				} else {
					if !reflect.DeepEqual(tt.expScopes, scopesList) {
						subT.Errorf("Scopes do not match, want: %v, got: %v", tt.expScopes, scopesList)
					}
				}

			}
		})
	}
}

func TestJwtConfig(t *testing.T) {
	tests := []struct {
		name  string
		hcl   string
		error string
	}{
		{
			"missing both signature_algorithm/jwks_url",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			  }
			}
			`,
			"signature_algorithm or jwks_url required",
		},
		{
			"signature_algorithm, missing key/key_file",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    signature_algorithm = "HS256"
			    header = "..."
			  }
			}
			`,
			"jwt key: read error: required: configured attribute or file",
		},
		{
			"ok: signature_algorithm + key + header",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    signature_algorithm = "HS256"
			    header = "..."
			    key = "..."
			  }
			}
			`,
			"",
		},
		{
			"ok: signature_algorithm + key + cookie",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    signature_algorithm = "HS256"
			    cookie = "..."
			    key = "..."
			  }
			}
			`,
			"",
		},
		{
			"ok: signature_algorithm + key + token_value",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    signature_algorithm = "HS256"
			    token_value = env.TOKEN
			    key = "..."
			  }
			}
			`,
			"",
		},
		{
			"token_value + header",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    signature_algorithm = "HS256"
			    token_value = env.TOKEN
			    header = "..."
			    key = "..."
			  }
			}
			`,
			"token source is invalid",
		},
		{
			"token_value + cookie",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    signature_algorithm = "HS256"
			    token_value = env.TOKEN
			    cookie = "..."
			    key = "..."
			  }
			}
			`,
			"token source is invalid",
		},
		{
			"cookie + header",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    signature_algorithm = "HS256"
			    cookie = "..."
			    header = "..."
			    key = "..."
			  }
			}
			`,
			"token source is invalid",
		},
		{
			"ok: signature_algorithm + key_file",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    signature_algorithm = "HS256"
			    header = "..."
			    key_file = "testdata/secret.txt"
			  }
			}
			`,
			"",
		},
		{
			"ok: jwks_url",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    jwks_url = "http://..."
			    header = "..."
			  }
			}
			`,
			"",
		},
		{
			"signature_algorithm + jwks_url",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    signature_algorithm = "HS256"
			    jwks_url = "http://..."
			    header = "..."
			  }
			}
			`,
			"signature_algorithm cannot be used together with jwks_url",
		},
		{
			"key + jwks_url",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    key = "..."
			    jwks_url = "http://..."
			    header = "..."
			  }
			}
			`,
			"key cannot be used together with jwks_url",
		},
		{
			"key_file + jwks_url",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    key_file = "..."
			    jwks_url = "http://..."
			    header = "..."
			  }
			}
			`,
			"key_file cannot be used together with jwks_url",
		},
		{
			"backend reference, missing jwks_url",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    backend = "foo"
			    header = "..."
			  }
			  backend "foo" {}
			}
			`,
			"backend not needed without jwks_url",
		},
		{
			"ok: jwks_url + backend reference",
			`
			server "test" {}
			definitions {
			  jwt "myac" {
			    backend = "foo"
			    header = "..."
			    jwks_url = "http://..."
			  }
			  backend "foo" {}
			}
			`,
			"",
		},
	}

	log, _ := logrustest.NewNullLogger()

	for _, tt := range tests {
		t.Run(tt.name, func(subT *testing.T) {
			conf, err := configload.LoadBytes([]byte(tt.hcl), "couper.hcl")
			if conf != nil {
				_, err = runtime.NewServerConfiguration(conf, log.WithContext(context.TODO()), nil)
			}

			var error = ""
			if err != nil {
				if _, ok := err.(errors.GoError); ok {
					error = err.(errors.GoError).LogError()
				} else {
					error = err.Error()
				}
			}

			if tt.error == "" && error == "" {
				return
			}

			expectedError := "configuration error: myac: " + tt.error

			if expectedError != error {
				subT.Errorf("%q: Unexpected configuration error:\n\tWant: %q\n\tGot:  %q", tt.name, expectedError, error)
			}
		})
	}
}

func newRSAKeyPair() (pubKeyBytes []byte, privKey *rsa.PrivateKey) {
	privKey, err := rsa.GenerateKey(rand.Reader, 2048)
	if err != nil {
		panic(err)
	}
	if e := privKey.Validate(); e != nil {
		panic(e)
	}

	pubKeyBytes = pem.EncodeToMemory(&pem.Block{
		Type:  "RSA PUBLIC KEY",
		Bytes: x509.MarshalPKCS1PublicKey(&privKey.PublicKey),
	})
	return
}

func setCookieAndHeader(req *http.Request, key, value string) *http.Request {
	req.Header.Set(key, value)
	req.Header.Set("Cookie", key+"="+value)
	return req
}

func setContext(req *http.Request) *http.Request {
	evalCtx := eval.ContextFromRequest(req)
	*req = *req.WithContext(evalCtx.WithClientRequest(req))
	return req
}

repository: kos-maverik/couper

repo_name: kos-maverik/couper


text:
@article{Wu2014,
author = {Wu, Tony C. and Thompson, Nicholas J. and Congreve, Daniel N. and Hontz, Eric and Yost, Shane R. and {Van Voorhis}, Troy and Baldo, Marc a.},
doi = {10.1063/1.4876600},
file = {:home/tonyw/Dropbox/Research/Article(Mendeley)/Wu et al. - 2014 - Singlet fission efficiency in tetracene-based organic solar cells.pdf:pdf},
issn = {0003-6951},
journal = {Applied Physics Letters},
month = may,
number = {19},
pages = {193901},
title = {{Singlet fission efficiency in tetracene-based organic solar cells}},
url = {http://scitation.aip.org/content/aip/journal/apl/104/19/10.1063/1.4876600},
volume = {104},
year = {2014}
}
@article{Hsu2011,
author = {Hsu, Yu-Ching and Wu, Tony Chang Chi and Cheng, I-Chun and Chen, Jian-Zhang and Yang, Mu-Rong},
doi = {10.1143/JJAP.50.06GF09},
file = {:home/tonyw/Dropbox/Research/Article(Mendeley)/Hsu et al. - 2011 - Dye-Sensitized Solar Cell with Photoanode Made with Polystyrene-Ball-Embedded TiO 2 Pastes.pdf:pdf},
issn = {0021-4922},
journal = {Japanese Journal of Applied Physics},
month = jun,
number = {6},
pages = {06GF09},
title = {{Dye-Sensitized Solar Cell with Photoanode Made with Polystyrene-Ball-Embedded TiO 2 Pastes}},
url = {http://stacks.iop.org/1347-4065/50/06GF09},
volume = {50},
year = {2011}
}
@article{yost2014transferable,
author = {Yost, Shane R and Lee, Jiye and Wilson, Mark W B and Wu, Tony and McMahon, David P and Parkhurst, Rebecca R and Thompson, Nicholas J and Congreve, Daniel N and Rao, Akshay and Johnson, Kerr and Others},
file = {:home/tonyw/Dropbox/Research/Article(Mendeley)/Yost et al. - 2014 - A transferable model for singlet-fission kinetics(2).pdf:pdf},
journal = {Nature chemistry},
publisher = {Nature Publishing Group},
title = {{A transferable model for singlet-fission kinetics}},
year = {2014}
}


text:
@article{Robertson-2020-An,
    title = "An integrated environmental analytics system (IDEAS) based on a DGGS",
    author = "Robertson, Colin  and
      Chaudhuri, Chiranjib  and
      Hojati, Majid  and
      Roberts, Steven A.",
    journal = "ISPRS Journal of Photogrammetry and Remote Sensing, Volume 162",
    volume = "162",
    year = "2020",
    publisher = "Elsevier BV",
    url = "https://aclanthology.org/G20-126001",
    doi = "10.1016/j.isprsjprs.2020.02.009",
    pages = "214--228",
}

repository: gwf-uwaterloo/gwf-publications

repo_name: gwf-uwaterloo/gwf-publications

branch_name: refs/heads/main

gha_language: Python


text:
require xorg-driver-input.inc

SUMMARY = "X.Org X server -- mouse input driver"

DESCRIPTION = "mouse is an Xorg input driver for mice. The driver \
supports most available mouse types and interfaces.  The mouse driver \
functions as a pointer input device, and may be used as the X server's \
core pointer. Multiple mice are supported by multiple instances of this \
driver."

LIC_FILES_CHKSUM = "file://COPYING;md5=90ea9f90d72b6d9327dede5ffdb2a510"

SRC_URI[md5sum] = "36b5b92000c4644f648b58a535e4ee73"
SRC_URI[sha256sum] = "5d601e4bae53d5e9ead4ecd700f1beb5aeaf78b79e634c4aa381a9ce00276488"

#
# debian
#
inherit debian-package
DEBIAN_SECTION = "x11"
DPR = "0"
DPN = "xserver-xorg-input-mouse"
DEBIAN_PATCH_TYPE = "quilt"
debian_patch_quilt() {
        if [ ! -s ${DEBIAN_UNPACK_DIR}/debian/patches/series ]; then
                bbfatal "no patch in series"
        elif test $(ls ${DEBIAN_UNPACK_DIR}/debian/patches/ | wc -l) -ne 1; then
                QUILT_PATCHES=${DEBIAN_UNPACK_DIR}/debian/patches \
                        quilt --quiltrc /dev/null push -a
        fi
}

repository: takuya-t/meta-debian

repo_name: takuya-t/meta-debian

branch_name: refs/heads/daisy


text:
# Copyright 2019 Arthur Sonzogni. All rights reserved.
# Use of this source code is governed by the MIT license that can be found in
# the LICENSE file.

message(STATUS "Checking for asm-dom: Please wait")
include(FetchContent)
FetchContent_Declare(asm-dom
  GIT_REPOSITORY https://github.com/mbasso/asm-dom
  GIT_TAG 49131a4ebe26383bafea213167561bffa2024f7c
)

FetchContent_GetProperties(asm-dom)
if(NOT asm-dom_POPULATED)
  FetchContent_Populate(asm-dom)
  add_library(asm-dom
    ${asm-dom_SOURCE_DIR}/cpp/asm-dom.cpp
    ${asm-dom_SOURCE_DIR}/cpp/asm-dom-server.cpp
    ${asm-dom_SOURCE_DIR}/cpp/asm-dom.hpp
    ${asm-dom_SOURCE_DIR}/cpp/asm-dom-server.hpp
  )
  set_property(TARGET asm-dom PROPERTY CXX_STANDARD 11)
  target_include_directories(asm-dom PUBLIC ${asm-dom_SOURCE_DIR}/cpp/)
  configure_file(
    ${asm-dom_SOURCE_DIR}/dist/cpp/asm-dom.js
    ${CMAKE_CURRENT_BINARY_DIR}/asm-dom.js
  )

  add_link_options(-sEXPORTED_RUNTIME_METHODS=['UTF8ToString'])
  add_link_options(-sWASM=1)
  add_link_options(--bind)
endif()
message(STATUS "Checking for asm-dom: DONE")

repository: ArthurSonzogni/asm-dom-cmake

repo_name: ArthurSonzogni/asm-dom-cmake

gha_language: CMake

extension: cmake